mktemp
mktemp command for node.js
Installation
$ npm install mktemp
Usage
var mktemp = require('mktemp');
mktemp.createFile('file-XXXXXX', function(err, path) {
if (err) throw err;
console.log(path);
});
mktemp.createFileSync('file-XXX');
mktemp.createDir('dir-XXXXX', function(err, path) {
if (err) throw err;
console.log(path);
});
mktemp.createDirSync('dir-XXX');
mktemp functions replace to unique name from "X" at near end of line.
mktemp.createFileSync('XXXXXXXXXXX');
mktemp.createFileSync('abc-XXXXXXX');
mktemp.createFileSync('XXX-XXXXXXX');
mktemp.createFileSync('XXX-XXX.tmp');
Functions
createFile(template, callback)
template
string - filename templatecallback
function(err, path) - callback function
err
- error objectpath
- replaced path
create blank file of unique filename.
permission is 0600
.
createFileSync(template)
template
string - filename templatereturn
string - replaced path
sync version createFile.
createDir(template, callback)
template
string - dirname templatecallback
function(err, path) - callback function
err
- error objectpath
- replaced path
create directory of unique dirname.
permission is 0700
.
createDirSync(template)
template
string - dirname templatereturn
string - replaced path
sync version createDir.
Test
$ npm install
$ npm test
Contributors
License
The MIT license. Please see LICENSE file.