tmp-dir

0.0.2 • Public • Published

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!

Usage

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()
})

API

var tmp = require('tmp-dir')

tmp(work)

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; dir is the absolute path to the directory, and cleanup is a function for you to call when you are done with the directory for clean-up.

Install

With npm installed, run

$ npm install tmp-dir

See Also

License

ISC

Readme

Keywords

Package Sidebar

Install

npm i tmp-dir

Weekly Downloads

1

Version

0.0.2

License

ISC

Last publish

Collaborators

  • noffle