Package Exports
- mktemp
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mktemp) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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); // match to /^file-[\da-zA-Z]{6}$/
});
mktemp.createFileSync('file-XXX');
// return value is match to /^file-[\da-zA-Z]{3}$/
mktemp.createDir('dir-XXXXX', function(err, path) {
if (err) throw err;
console.log(path); // match to /^dir-[\da-zA-Z]{5}$/
});
mktemp.createDirSync('dir-XXX');
// return value is match to /^dir-[\da-zA-Z]{3}$/
mktemp functions replace to unique name from "X" at near end of line.
'XXXXXXXXXXX' // /^[\da-zA-Z]{11}$/
'abc-XXXXXXX' // /^abc-[\da-zA-Z]{7}$/
'XXX-XXXXXXX' // /^XXX-[\da-zA-Z]{7}$/
'XXX-XXX.tmp' // /^XXX-[\da-zA-Z]{3}\.tmp$/
Functions
createFile(template, callback)
template
string - filename templatecallback
function(err, path) - callback functionerr
- 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 functionerr
- 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.