@@ -50,15 +50,6 @@ dependency to version 0.0.33.
5050For node versions < 0.8 you must limit your node-tmp dependency to
5151versions < 0.0.33.
5252
53- ### Node Versions < 8.12.0
54-
55- The SIGINT handler will not work correctly with versions of NodeJS < 8.12.0.
56-
57- ### Windows
58-
59- Signal handlers for SIGINT will not work. Pressing CTRL-C will leave behind
60- temporary files and directories.
61-
6253## How to install
6354
6455``` bash
@@ -74,7 +65,7 @@ Please also check [API docs][4].
7465Simple temporary file creation, the file will be closed and unlinked on process exit.
7566
7667``` javascript
77- var tmp = require (' tmp' );
68+ const tmp = require (' tmp' );
7869
7970tmp .file (function _tempFileCreated (err , path , fd , cleanupCallback ) {
8071 if (err) throw err;
@@ -94,9 +85,9 @@ tmp.file(function _tempFileCreated(err, path, fd, cleanupCallback) {
9485A synchronous version of the above.
9586
9687``` javascript
97- var tmp = require (' tmp' );
88+ const tmp = require (' tmp' );
9889
99- var tmpobj = tmp .fileSync ();
90+ const tmpobj = tmp .fileSync ();
10091console .log (' File: ' , tmpobj .name );
10192console .log (' Filedescriptor: ' , tmpobj .fd );
10293
@@ -117,7 +108,7 @@ Simple temporary directory creation, it will be removed on process exit.
117108If the directory still contains items on process exit, then it won't be removed.
118109
119110``` javascript
120- var tmp = require (' tmp' );
111+ const tmp = require (' tmp' );
121112
122113tmp .dir (function _tempDirCreated (err , path , cleanupCallback ) {
123114 if (err) throw err;
@@ -137,9 +128,9 @@ you can pass the `unsafeCleanup` option when creating it.
137128A synchronous version of the above.
138129
139130``` javascript
140- var tmp = require (' tmp' );
131+ const tmp = require (' tmp' );
141132
142- var tmpobj = tmp .dirSync ();
133+ const tmpobj = tmp .dirSync ();
143134console .log (' Dir: ' , tmpobj .name );
144135// Manual cleanup
145136tmpobj .removeCallback ();
@@ -155,7 +146,7 @@ It is possible with this library to generate a unique filename in the specified
155146directory.
156147
157148``` javascript
158- var tmp = require (' tmp' );
149+ const tmp = require (' tmp' );
159150
160151tmp .tmpName (function _tempNameGenerated (err , path ) {
161152 if (err) throw err;
@@ -169,9 +160,9 @@ tmp.tmpName(function _tempNameGenerated(err, path) {
169160A synchronous version of the above.
170161
171162``` javascript
172- var tmp = require (' tmp' );
163+ const tmp = require (' tmp' );
173164
174- var name = tmp .tmpNameSync ();
165+ const name = tmp .tmpNameSync ();
175166console .log (' Created temporary filename: ' , name);
176167```
177168
@@ -182,9 +173,9 @@ console.log('Created temporary filename: ', name);
182173Creates a file with mode ` 0644 ` , prefix will be ` prefix- ` and postfix will be ` .txt ` .
183174
184175``` javascript
185- var tmp = require (' tmp' );
176+ const tmp = require (' tmp' );
186177
187- tmp .file ({ mode: 0644 , prefix: ' prefix-' , postfix: ' .txt' }, function _tempFileCreated (err , path , fd ) {
178+ tmp .file ({ mode: 0o644 , prefix: ' prefix-' , postfix: ' .txt' }, function _tempFileCreated (err , path , fd ) {
188179 if (err) throw err;
189180
190181 console .log (' File: ' , path);
@@ -197,9 +188,9 @@ tmp.file({ mode: 0644, prefix: 'prefix-', postfix: '.txt' }, function _tempFileC
197188A synchronous version of the above.
198189
199190``` javascript
200- var tmp = require (' tmp' );
191+ const tmp = require (' tmp' );
201192
202- var tmpobj = tmp .fileSync ({ mode: 0644 , prefix: ' prefix-' , postfix: ' .txt' });
193+ const tmpobj = tmp .fileSync ({ mode: 0o644 , prefix: ' prefix-' , postfix: ' .txt' });
203194console .log (' File: ' , tmpobj .name );
204195console .log (' Filedescriptor: ' , tmpobj .fd );
205196```
@@ -221,7 +212,7 @@ descriptor. Two options control how the descriptor is managed:
221212 longer needed.
222213
223214``` javascript
224- var tmp = require (' tmp' );
215+ const tmp = require (' tmp' );
225216
226217tmp .file ({ discardDescriptor: true }, function _tempFileCreated (err , path , fd , cleanupCallback ) {
227218 if (err) throw err;
@@ -231,7 +222,7 @@ tmp.file({ discardDescriptor: true }, function _tempFileCreated(err, path, fd, c
231222```
232223
233224``` javascript
234- var tmp = require (' tmp' );
225+ const tmp = require (' tmp' );
235226
236227tmp .file ({ detachDescriptor: true }, function _tempFileCreated (err , path , fd , cleanupCallback ) {
237228 if (err) throw err;
@@ -248,9 +239,9 @@ tmp.file({ detachDescriptor: true }, function _tempFileCreated(err, path, fd, cl
248239Creates a directory with mode ` 0755 ` , prefix will be ` myTmpDir_ ` .
249240
250241``` javascript
251- var tmp = require (' tmp' );
242+ const tmp = require (' tmp' );
252243
253- tmp .dir ({ mode: 0750 , prefix: ' myTmpDir_' }, function _tempDirCreated (err , path ) {
244+ tmp .dir ({ mode: 0o750 , prefix: ' myTmpDir_' }, function _tempDirCreated (err , path ) {
254245 if (err) throw err;
255246
256247 console .log (' Dir: ' , path);
@@ -262,9 +253,9 @@ tmp.dir({ mode: 0750, prefix: 'myTmpDir_' }, function _tempDirCreated(err, path)
262253Again, a synchronous version of the above.
263254
264255``` javascript
265- var tmp = require (' tmp' );
256+ const tmp = require (' tmp' );
266257
267- var tmpobj = tmp .dirSync ({ mode: 0750 , prefix: ' myTmpDir_' });
258+ const tmpobj = tmp .dirSync ({ mode: 0750 , prefix: ' myTmpDir_' });
268259console .log (' Dir: ' , tmpobj .name );
269260```
270261
@@ -277,7 +268,7 @@ require tmp to create your temporary filesystem object in a different place than
277268default ` tmp.tmpdir ` .
278269
279270``` javascript
280- var tmp = require (' tmp' );
271+ const tmp = require (' tmp' );
281272
282273tmp .dir ({ template: ' tmp-XXXXXX' }, function _tempDirCreated (err , path ) {
283274 if (err) throw err;
@@ -291,9 +282,9 @@ tmp.dir({ template: 'tmp-XXXXXX' }, function _tempDirCreated(err, path) {
291282This will behave similarly to the asynchronous version.
292283
293284``` javascript
294- var tmp = require (' tmp' );
285+ const tmp = require (' tmp' );
295286
296- var tmpobj = tmp .dirSync ({ template: ' tmp-XXXXXX' });
287+ const tmpobj = tmp .dirSync ({ template: ' tmp-XXXXXX' });
297288console .log (' Dir: ' , tmpobj .name );
298289```
299290
@@ -305,9 +296,9 @@ The function accepts all standard options, e.g. `prefix`, `postfix`, `dir`, and
305296You can also leave out the options altogether and just call the function with a callback as first parameter.
306297
307298``` javascript
308- var tmp = require (' tmp' );
299+ const tmp = require (' tmp' );
309300
310- var options = {};
301+ const options = {};
311302
312303tmp .tmpName (options, function _tempNameGenerated (err , path ) {
313304 if (err) throw err;
@@ -322,19 +313,22 @@ The `tmpNameSync()` function works similarly to `tmpName()`.
322313Again, you can leave out the options altogether and just invoke the function without any parameters.
323314
324315``` javascript
325- var tmp = require (' tmp' );
326- var options = {};
327- var tmpname = tmp .tmpNameSync (options);
316+ const tmp = require (' tmp' );
317+ const options = {};
318+ const tmpname = tmp .tmpNameSync (options);
328319console .log (' Created temporary filename: ' , tmpname);
329320```
330321
331322## Graceful cleanup
332323
333- One may want to cleanup the temporary files even when an uncaught exception
334- 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:
335329
336330``` javascript
337- var tmp = require (' tmp' );
331+ const tmp = require (' tmp' );
338332
339333tmp .setGracefulCleanup ();
340334```
0 commit comments