temporary-directory
create a random temporary directory and easily clean it up when you are done
installation
npm install temporary-directory
example
var tmp =
API
var tmpdir = require('temporary-directory')
returns a constructor function that can be used to create new temporary directories
tmpdir([name], callback)
name
is optional, if you pass it then your tmpdir name will start with name-<random-id>
, otherwise it defaults to tmp-<random-id>
callback
will be called with err, dir, cleanup
err
is if there was an error creating your tmpdirdir
is a string of the absolute path to your tmpdir (inside yourrequire('os').tmpdir()
)cleanup
is a function you can call (if you want) that will destroy the tmpdir and everything in it. it takes a singlecallback
argument that takes a singleerror
argument, but the callback is optional.