mktemp
mktemp 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 random string from placeholder of "X" near end of line.
'XXXXXXXXXXX'
'abc-XXXXXXX'
'XXX-XXXXXXX'
'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 random 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 random 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.