mktmp
v1.0.1
Published
mktemp command for node.js
Readme
mktemp
mktemp command for node.js
Installation
$ npm install mktempUsage
var mktemp = require('mktemp');
mktemp.createFile('XXXXX.txt', function(err, path) {
if (err) throw err;
// path match a /^[\da-zA-Z]{5}\.txt$/
console.log(path);
});
// return value match a /^[\da-zA-Z]{5}\.tmp$/
mktemp.createFileSync('XXXXX.tmp');
mktemp.createDir('XXXXXXX', function(err, path) {
if (err) throw err;
// path match a /^[\da-zA-Z]{7}$/
console.log(path);
});
// return value match a /^XXX-[\da-zA-Z]{3}$/
mktemp.createDirSync('XXX-XXX');mktemp functions are replace to random string from placeholder "X" in template. see example:
mktemp.createFileSync('XXXXXXX'); // match a /^[\da-zA-Z]{7}$/
mktemp.createFileSync('XXX.tmp'); // match a /^[\da-zA-Z]{3}\.tmp$/
mktemp.createFileSync('XXX-XXX'); // match a /^XXX-[\da-zA-Z]{3}$/Functions
createFile(template, callback)
templateString- filename template
callbackfunction(err, path)- callback functionerr:Error|Null- error objectpath:String- path
create blank file of unique filename.
permission is 0600.
createFileSync(template)
templateString- filename template
returnString- path
sync version createFile.
createDir(template, callback)
templateString- dirname template
callbackfunction(err, path)- callback functionerr:Error|Null- error objectpath:String- path
create directory of unique dirname.
permission is 0700.
createDirSync(template)
templateString- dirname template
returnString- path
sync version createDir.
Test
$ npm install
$ npm testContributors
License
The MIT license. Please see LICENSE file.
