1.0.1 • Published 3 years ago
tmp-path v1.0.1
tmp-path
Create a temporary cache directory, optionally scoped to the current working directory.
Install
$ npm install tmp-path
Usage
Node.js / CommonJS:
const { getTmpPath } = require('tmp-path')
ESNext / TypeScript:
import { getTmpPath } from 'tmp-path'
Standard use:
const tmpPath = getTempPath('my-package')
// Returns: /var/folders/pc/prj9q5qx5zxczzn1x9xb814w0000gp/T/my-package
Scoped to a specific directory:
const cwdTmpPath = getTempPath('my-package', { cwd: process.env.cwd() })
// Returns /var/folders/pc/prj9q5qx5zxczzn1x9xb814w0000gp/T/my-package/ee35e7c782791419f29316f183d5d6d3
Signature:
/**
* @param name - Name of your module/scope of the tmp-path.
* @param options - Options
* @returns Ensured absolute tmp path
*/
function getTmpPath(name: string, options: Options = {}): string
Options
cwd
Type: string
Current working directory.
If provided, the value will be converted to a non-secure MD5 hash and appended to the returned temporary path to create a scoped tmp-path.
fs
Type: object
Provide an alternative Node fs
module.
fileMode
Type: number
Default: 0777
File permissions mode.