Create unique tempdir directories.
npm install tmp-dir> Create unique tempdir directories.
---
You're probably looking for node-tmp.
I wrote this module while offline and wasn't sure if anything like it existed.
Turns out it did, and with tests! So you really ought to use
node-tmp instead!
---
Use os.tmpdir() plus a GUID to create temporary directories in a
laissez-faire manner. Never worry about deducing your own unique name and
location for a throw-away directory!
``js
var tmp = require('tmp-dir')
tmp(function (err, dir, cleanup) {
if (err) return cleanup()
// write a single file
fs.writeFileSync(path.join(dir, 'foo'), 'hello warld!')
// callback that cleans up the directory
cleanup()
})
`
`js`
var tmp = require('tmp-dir')
Creates a new temporary directory in /tmp/tmp-dir/some-unique-identifier.work gets called once the directory is created, and has the form function
(err, dir, cleanup) {}. err is set if the temp dir couldn't be created; dircleanup
is the absolute path to the directory, and is a function for you to
call when you are done with the directory for clean-up.
With npm installed, run
``
$ npm install tmp-dir
ISC