JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 635601
  • Score
    100M100P100Q174932F
  • License MIT

mktemp command for node.js

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

Build Status Dependency Status NPM version

mktemp command for node.js

Installation

$ npm install mktemp

Usage

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)

  • template
    • String - filename template
  • callback
    • function(err, path) - callback function
      • err : Error|Null - error object
      • path : String - path

create blank file of unique filename. permission is 0600.

createFileSync(template)

  • template
    • String - filename template
  • return
    • String - path

sync version createFile.

createDir(template, callback)

  • template
    • String - dirname template
  • callback
    • function(err, path) - callback function
      • err : Error|Null - error object
      • path : String - path

create directory of unique dirname. permission is 0700.

createDirSync(template)

  • template
    • String - dirname template
  • return
    • String - path

sync version createDir.

Test

$ npm install
$ npm test

Contributors

License

The MIT license. Please see LICENSE file.