3.0.2 • Published 3 years ago

@particle/tmp v3.0.2

Weekly downloads
58
License
UNLICENSED
Repository
-
Last release
3 years ago

@particle/tmp

Tools for working with temporary files and directories.

Installation

npm install @particle/tmp --save
const tmp = require('@particle/tmp');

API

@particle/tmp


tmp.setGracefulCleanup ⇒ undefined

Enables cleanup of temporary files even when an uncaught exception occurs

Kind: static property of @particle/tmp
Example

tmp.setGracefulCleanup();

tmp.createDir(options) ⇒ Promise.<(TmpDir|Error)>

Create a new directory within the user's temp dir

Kind: static method of @particle/tmp
Returns: Promise.<(TmpDir|Error)> - A resolved promise containing either info about the newly created directory or an error

ParamTypeDescription
optionsTmpOptionsOptions object

Example

const dir = await tmp.createDir();
dir.path; // '/path/to/the/new/tmp/dir'
await dir.cleanup(); // remove newly created temp directory

tmp.createFile(options) ⇒ Promise.<(TmpFile|Error)>

Create a new file within the user's temp dir

Kind: static method of @particle/tmp
Returns: Promise.<(TmpFile|Error)> - A resolved promise containing either info about the newly created file or an error

ParamTypeDescription
optionsTmpOptionsOptions object

Example

const file = await tmp.createFile();
file.fd; // 61344
file.path; // '/path/to/the/new/tmp/file'
await file.cleanup(); // remove newly created temp file

@particle/tmp~TmpOptions : Object

Kind: inner typedef of @particle/tmp
Properties

NameTypeDefaultDescription
modestring"0600"File mode to create with, uses 0600 on file creation and 0700 on directory creation by default
prefixstring"particle-"Prefix assigned to created files and directories
dirstring"<based on environment>"Temp directory location
triesnumber3Number of times to try getting a unique filename before giving up
keepbooleanfalseRetain the created temporary file or directory
unsafeCleanupbooleantrueRecursively remove the created temporary directory, even when it's not empty

@particle/tmp~TmpDir : Object

Kind: inner typedef of @particle/tmp
Properties

NameTypeDescription
pathstringFilename of newly created temp directory
cleanupfunctionFunction to call to remove newly created temp directory

@particle/tmp~TmpFile : Object

Kind: inner typedef of @particle/tmp
Properties

NameTypeDescription
pathstringFilename of newly created temp file
fdnumberFile descriptor of newly created temp file
cleanupfunctionFunction to call to remove newly created temp file

NOTE: Unfortunately, docs have a nasty habit of falling out of date. When in doubt, check usage in tests

3.0.2

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.0.2

3 years ago

2.0.1

4 years ago

2.0.0

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago