Skip to content
This repository has been archived by the owner on Aug 8, 2020. It is now read-only.

avajs/unique-temp-dir

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

unique-temp-dir Build Status

Provides a uniquely named temp directory

Install

$ npm install unique-temp-dir

Usage

const uniqueTempDir = require('unique-temp-dir');

uniqueTempDir();
//=> '/var/folders/2_/zg9h6_xd4r3_z7c07s0cn8mw0000gn/T/PpCfz55ANU2hdwnGzgny'

uniqueTempDir();
//=> '/var/folders/2_/zg9h6_xd4r3_z7c07s0cn8mw0000gn/T/qfqafhh1FJulehbCDAPk'

API

uniqueTempDir(options?)

Returns a string that represents a unique directory inside the systems temp directory.

options

Type: object

create

Type: boolean
Default: false

If true, the directory will be created synchronously before returning.

length

Type: number
Default: 20

The length of the directory name inside the temp directory.

thunk

Type: boolean
Default: false

If true, returns a thunk function for path.join(uniqueTempDir, ... additionalArgs). Useful for filling your directory up with stuff.

const uniqueTempDir = require('unique-temp-dir');
const tempDir = uniqueTempDir({thunk: true});

tempDir()
//=> '/user/temp/uniqueId'

tempDir('foo')
//=> '/user/temp/uniqueId/foo'

tempDir('bar')
//=> '/user/temp/uniqueId/bar'

About

Provides a uniquely named temp directory

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published