From 40427ffa10fa00302acfa57b9bff66427be3ef02 Mon Sep 17 00:00:00 2001 From: Carsten Klein Date: Sat, 6 Oct 2018 20:00:46 +0200 Subject: [PATCH 1/2] fix gh-179: template no longer accepts arbitrary paths cleanup documentation --- README.md | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 477c007..31d5c6b 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,10 @@ a six letter random identifier. And just in case that you do not have that much entropy left on your system, Tmp will fall back to pseudo random numbers. You can set whether you want to remove the temporary file on process exit or -not, and the destination directory can also be set. +not. + +And if you do not want to store your temporary directories and files in the +standard OS temporary directory, then you are free to override that as well. ## An Important Note on Compatibility @@ -285,12 +288,16 @@ console.log('Dir: ', tmpobj.name); ### Asynchronous filename generation -The `tmpName()` function accepts the `prefix`, `postfix`, `dir`, etc. parameters also: +Using `tmpName()` you can create temporary file names asynchronously. +The function accepts all standard options, e.g. `prefix`, `postfix`, `dir`, and so on. +And you can also leave out the options altogether and just call the function with a callback as first parameter. ```javascript var tmp = require('tmp'); -tmp.tmpName({ template: '/tmp/tmp-XXXXXX' }, function _tempNameGenerated(err, path) { +var options = {}; + +tmp.tmpName(options, function _tempNameGenerated(err, path) { if (err) throw err; console.log('Created temporary filename: ', path); @@ -300,10 +307,12 @@ tmp.tmpName({ template: '/tmp/tmp-XXXXXX' }, function _tempNameGenerated(err, pa ### Synchronous filename generation The `tmpNameSync()` function works similarly to `tmpName()`. +Again, you can leave out the options altogether and just invoke the function without any parameters. ```javascript var tmp = require('tmp'); -var tmpname = tmp.tmpNameSync({ template: '/tmp/tmp-XXXXXX' }); +var options = {}; +var tmpname = tmp.tmpNameSync(options); console.log('Created temporary filename: ', tmpname); ``` @@ -328,8 +337,8 @@ All options are optional :) * `template`: [`mkstemp`][3] like filename template, no default * `dir`: the optional temporary directory, fallbacks to system default (guesses from environment) * `tries`: how many times should the function try to get a unique filename before giving up, default `3` - * `keep`: signals that the temporary file or directory should not be deleted on exit, default is `false`, means delete - * Please keep in mind that it is recommended in this case to call the provided `cleanupCallback` function manually. + * `keep`: signals that the temporary file or directory should not be deleted on exit, default is `false` + * In order to clean up, you will have to call the provided `cleanupCallback` function manually. * `unsafeCleanup`: recursively removes the created temporary directory, even when it's not empty. default is `false` [1]: http://nodejs.org/ From 5f991d2f4e5c49149934cbb5261654270834d2bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?KARASZI=20Istv=C3=A1n?= Date: Tue, 29 Jan 2019 11:19:30 +0100 Subject: [PATCH 2/2] Remove ands from the beginning of the sentences --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 31d5c6b..3eb6897 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ entropy left on your system, Tmp will fall back to pseudo random numbers. You can set whether you want to remove the temporary file on process exit or not. -And if you do not want to store your temporary directories and files in the +If you do not want to store your temporary directories and files in the standard OS temporary directory, then you are free to override that as well. ## An Important Note on Compatibility @@ -290,7 +290,8 @@ console.log('Dir: ', tmpobj.name); Using `tmpName()` you can create temporary file names asynchronously. The function accepts all standard options, e.g. `prefix`, `postfix`, `dir`, and so on. -And you can also leave out the options altogether and just call the function with a callback as first parameter. + +You can also leave out the options altogether and just call the function with a callback as first parameter. ```javascript var tmp = require('tmp');