You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One may want to cleanup the temporary files even when an uncaught exception
332
-
occurs. To enforce this, you can call the `setGracefulCleanup()` method:
324
+
If graceful cleanup is set, tmp will remove all controlled temporary objects on process exit, otherwise the
325
+
temporary objects will remain in place, waiting to be cleaned up on system restart or otherwise scheduled temporary
326
+
object removal.
327
+
328
+
To enforce this, you can call the `setGracefulCleanup()` method:
333
329
334
330
```javascript
335
-
var tmp =require('tmp');
331
+
consttmp=require('tmp');
336
332
337
333
tmp.setGracefulCleanup();
338
334
```
@@ -341,16 +337,25 @@ tmp.setGracefulCleanup();
341
337
342
338
All options are optional :)
343
339
344
-
*`name`: a fixed name that overrides random name generation
345
-
*`mode`: the file mode to create with, it fallbacks to `0600` on file creation and `0700` on directory creation
346
-
*`prefix`: the optional prefix, fallbacks to `tmp-` if not provided
347
-
*`postfix`: the optional postfix, fallbacks to `.tmp` on file creation
348
-
*`template`: [`mkstemp`][3] like filename template, no default
349
-
*`dir`: the optional temporary directory, fallbacks to system default (guesses from environment)
340
+
*`name`: a fixed name that overrides random name generation, the name must be relative and must not contain path segments
341
+
*`mode`: the file mode to create with, falls back to `0o600` on file creation and `0o700` on directory creation
342
+
*`prefix`: the optional prefix, defaults to `tmp`
343
+
*`postfix`: the optional postfix
344
+
*`template`: [`mkstemp`][3] like filename template, no default, can be either an absolute or a relative path that resolves
345
+
to a relative path of the system's default temporary directory, must include `XXXXXX` once for random name generation, e.g.
346
+
'foo/bar/XXXXXX'. Absolute paths are also fine as long as they are relative to os.tmpdir().
347
+
Any directories along the so specified path must exist, otherwise a ENOENT error will be thrown upon access,
348
+
as tmp will not check the availability of the path, nor will it establish the requested path for you.
349
+
*`dir`: the optional temporary directory that must be relative to the system's default temporary directory.
350
+
absolute paths are fine as long as they point to a location under the system's default temporary directory.
351
+
Any directories along the so specified path must exist, otherwise a ENOENT error will be thrown upon access,
352
+
as tmp will not check the availability of the path, nor will it establish the requested path for you.
350
353
*`tries`: how many times should the function try to get a unique filename before giving up, default `3`
351
354
*`keep`: signals that the temporary file or directory should not be deleted on exit, default is `false`
352
355
* In order to clean up, you will have to call the provided `cleanupCallback` function manually.
353
356
*`unsafeCleanup`: recursively removes the created temporary directory, even when it's not empty. default is `false`
357
+
*`detachDescriptor`: detaches the file descriptor, caller is responsible for closing the file, tmp will no longer try closing the file during garbage collection
358
+
*`discardDescriptor`: discards the file descriptor (closes file, fd is -1), tmp will no longer try closing the file during garbage collection
0 commit comments