Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mktemp

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mktemp

mktemp command for node.js

  • 0.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
280K
decreased by-17.82%
Maintainers
1
Weekly downloads
 
Created
Source

mktemp Build Status

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);  // match for /^file-[\da-zA-Z]{6}$/
});

mktemp.createFileSync('file-XXX');
// return value is match for /^file-[\da-zA-Z]{3}$/

mktemp.createDir('dir-XXXXX', function(err, path) {
  if (err) throw err;
  console.log(path);  // match for /^dir-[\da-zA-Z]{5}$/
});

mktemp.createDirSync('dir-XXX');
// return value is match for /^dir-[\da-zA-Z]{3}$/

mktemp functions replace to random string from placeholder of "X" 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 template
  • callback function(err, path) - callback function
    • err - error object
    • path - replaced path

create blank file of random filename. permission is 0600.

createFileSync(template)

  • template string - filename template
  • return string - replaced path

sync version createFile.

createDir(template, callback)

  • template string - dirname template
  • callback function(err, path) - callback function
    • err - error object
    • path - replaced path

create directory of random dirname. permission is 0700.

createDirSync(template)

  • template string - dirname template
  • return string - replaced path

sync version createDir.

Test

$ npm install
$ npm test

Contributors

License

The MIT License. Please see LICENSE file.

FAQs

Package last updated on 06 Apr 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc