-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemp-dir.ts
More file actions
63 lines (59 loc) · 1.44 KB
/
temp-dir.ts
File metadata and controls
63 lines (59 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**
* @fileoverview Temporary directory environment variable getters.
* Different platforms use different environment variables for temp directories.
*/
import { getEnvValue } from './rewire'
/**
* TEMP environment variable.
* Windows temporary directory path.
*
* @returns The Windows temp directory path, or `undefined` if not set
*
* @example
* ```typescript
* import { getTemp } from '@socketsecurity/lib/env/temp-dir'
*
* const temp = getTemp()
* // e.g. 'C:\\Windows\\Temp' or undefined
* ```
*/
/*@__NO_SIDE_EFFECTS__*/
export function getTemp(): string | undefined {
return getEnvValue('TEMP')
}
/**
* TMP environment variable.
* Alternative temporary directory path.
*
* @returns The alternative temp directory path, or `undefined` if not set
*
* @example
* ```typescript
* import { getTmp } from '@socketsecurity/lib/env/temp-dir'
*
* const tmp = getTmp()
* // e.g. '/tmp' or undefined
* ```
*/
/*@__NO_SIDE_EFFECTS__*/
export function getTmp(): string | undefined {
return getEnvValue('TMP')
}
/**
* TMPDIR environment variable.
* Unix/macOS temporary directory path.
*
* @returns The Unix/macOS temp directory path, or `undefined` if not set
*
* @example
* ```typescript
* import { getTmpdir } from '@socketsecurity/lib/env/temp-dir'
*
* const tmpdir = getTmpdir()
* // e.g. '/tmp' or undefined
* ```
*/
/*@__NO_SIDE_EFFECTS__*/
export function getTmpdir(): string | undefined {
return getEnvValue('TMPDIR')
}