{ "name": "tmp", "version": "0.0.24", "description": "Temporary file and directory creator", "author": { "name": "KARASZI István", "email": "github@spam.raszi.hu", "url": "http://raszi.hu/" }, "homepage": "http://github.com/raszi/node-tmp", "keywords": [ "temporary", "tmp", "temp", "tempdir", "tempfile", "tmpdir", "tmpfile" ], "licenses": [ { "type": "MIT", "url": "http://opensource.org/licenses/MIT" } ], "repository": { "type": "git", "url": "git://github.com/raszi/node-tmp.git" }, "bugs": { "url": "http://github.com/raszi/node-tmp/issues" }, "main": "lib/tmp.js", "scripts": { "test": "vows test/*-test.js" }, "engines": { "node": ">=0.4.0" }, "dependencies": {}, "devDependencies": { "vows": "~0.7.0" }, "readme": "# Tmp\n\nA simple temporary file and directory creator for [node.js.][1]\n\n[![Build Status](https://secure.travis-ci.org/raszi/node-tmp.png?branch=master)](http://travis-ci.org/raszi/node-tmp)\n\n## About\n\nThe main difference between bruce's [node-temp][2] is that mine more\naggressively checks for the existence of the newly created temporary file and\ncreates the new file with `O_EXCL` instead of simple `O_CREAT | O_RDRW`, so it\nis safer.\n\nThe API is slightly different as well, Tmp does not yet provide synchronous\ncalls and all the parameters are optional.\n\nYou can set whether you want to remove the temporary file on process exit or\nnot, and the destination directory can also be set.\n\n## How to install\n\n```bash\nnpm install tmp\n```\n\n## Usage\n\n### File creation\n\nSimple temporary file creation, the file will be unlinked on process exit.\n\n```javascript\nvar tmp = require('tmp');\n\ntmp.file(function _tempFileCreated(err, path, fd) {\n if (err) throw err;\n\n console.log(\"File: \", path);\n console.log(\"Filedescriptor: \", fd);\n});\n```\n\n### Directory creation\n\nSimple temporary directory creation, it will be removed on process exit.\n\nIf the directory still contains items on process exit, then it won't be removed.\n\n```javascript\nvar tmp = require('tmp');\n\ntmp.dir(function _tempDirCreated(err, path) {\n if (err) throw err;\n\n console.log(\"Dir: \", path);\n});\n```\n\nIf you want to cleanup the directory even when there are entries in it, then\nyou can pass the `unsafeCleanup` option when creating it.\n\n### Filename generation\n\nIt is possible with this library to generate a unique filename in the specified\ndirectory.\n\n```javascript\nvar tmp = require('tmp');\n\ntmp.tmpName(function _tempNameGenerated(err, path) {\n if (err) throw err;\n\n console.log(\"Created temporary filename: \", path);\n});\n```\n\n## Advanced usage\n\n### File creation\n\nCreates a file with mode `0644`, prefix will be `prefix-` and postfix will be `.txt`.\n\n```javascript\nvar tmp = require('tmp');\n\ntmp.file({ mode: 0644, prefix: 'prefix-', postfix: '.txt' }, function _tempFileCreated(err, path, fd) {\n if (err) throw err;\n\n console.log(\"File: \", path);\n console.log(\"Filedescriptor: \", fd);\n});\n```\n\n### Directory creation\n\nCreates a directory with mode `0755`, prefix will be `myTmpDir_`.\n\n```javascript\nvar tmp = require('tmp');\n\ntmp.dir({ mode: 0750, prefix: 'myTmpDir_' }, function _tempDirCreated(err, path) {\n if (err) throw err;\n\n console.log(\"Dir: \", path);\n});\n```\n\n### mkstemps like\n\nCreates a new temporary directory with mode `0700` and filename like `/tmp/tmp-nk2J1u`.\n\n```javascript\nvar tmp = require('tmp');\n\ntmp.dir({ template: '/tmp/tmp-XXXXXX' }, function _tempDirCreated(err, path) {\n if (err) throw err;\n\n console.log(\"Dir: \", path);\n});\n```\n\n### Filename generation\n\nThe `tmpName()` function accepts the `prefix`, `postfix`, `dir`, etc. parameters also:\n\n```javascript\nvar tmp = require('tmp');\n\ntmp.tmpName({ template: '/tmp/tmp-XXXXXX' }, function _tempNameGenerated(err, path) {\n if (err) throw err;\n\n console.log(\"Created temporary filename: \", path);\n});\n```\n\n## Graceful cleanup\n\nOne may want to cleanup the temporary files even when an uncaught exception\noccurs. To enforce this, you can call the `setGracefulCleanup()` method:\n\n```javascript\nvar tmp = require('tmp');\n\ntmp.setGracefulCleanup();\n```\n\n## Options\n\nAll options are optional :)\n\n * `mode`: the file mode to create with, it fallbacks to `0600` on file creation and `0700` on directory creation\n * `prefix`: the optional prefix, fallbacks to `tmp-` if not provided\n * `postfix`: the optional postfix, fallbacks to `.tmp` on file creation\n * `template`: [`mkstemps`][3] like filename template, no default\n * `dir`: the optional temporary directory, fallbacks to system default (guesses from environment)\n * `tries`: how many times should the function try to get a unique filename before giving up, default `3`\n * `keep`: signals that the temporary file or directory should not be deleted on exit, default is `false`, means delete\n * `unsafeCleanup`: recursively removes the created temporary directory, even when it's not empty. default is `false`\n\n[1]: http://nodejs.org/\n[2]: https://github.com/bruce/node-temp\n[3]: http://www.kernel.org/doc/man-pages/online/pages/man3/mkstemp.3.html\n", "readmeFilename": "README.md", "_id": "tmp@0.0.24", "_shasum": "d6a5e198d14a9835cc6f2d7c3d9e302428c8cf12", "_resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.24.tgz", "_from": "tmp@0.0.24" }