-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxdg.ts
More file actions
63 lines (59 loc) · 1.59 KB
/
xdg.ts
File metadata and controls
63 lines (59 loc) · 1.59 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 XDG Base Directory Specification environment variable getters.
* Provides access to XDG user directories on Unix systems.
*/
import { getEnvValue } from './rewire'
/**
* XDG_CACHE_HOME environment variable.
* XDG Base Directory specification cache directory.
*
* @returns The XDG cache directory path, or `undefined` if not set
*
* @example
* ```typescript
* import { getXdgCacheHome } from '@socketsecurity/lib/env/xdg'
*
* const cacheDir = getXdgCacheHome()
* // e.g. '/tmp/.cache' or undefined
* ```
*/
/*@__NO_SIDE_EFFECTS__*/
export function getXdgCacheHome(): string | undefined {
return getEnvValue('XDG_CACHE_HOME')
}
/**
* XDG_CONFIG_HOME environment variable.
* XDG Base Directory specification config directory.
*
* @returns The XDG config directory path, or `undefined` if not set
*
* @example
* ```typescript
* import { getXdgConfigHome } from '@socketsecurity/lib/env/xdg'
*
* const configDir = getXdgConfigHome()
* // e.g. '/tmp/.config' or undefined
* ```
*/
/*@__NO_SIDE_EFFECTS__*/
export function getXdgConfigHome(): string | undefined {
return getEnvValue('XDG_CONFIG_HOME')
}
/**
* XDG_DATA_HOME environment variable.
* Points to the user's data directory on Unix systems.
*
* @returns The XDG data directory path, or `undefined` if not set
*
* @example
* ```typescript
* import { getXdgDataHome } from '@socketsecurity/lib/env/xdg'
*
* const dataDir = getXdgDataHome()
* // e.g. '/tmp/.local/share' or undefined
* ```
*/
/*@__NO_SIDE_EFFECTS__*/
export function getXdgDataHome(): string | undefined {
return getEnvValue('XDG_DATA_HOME')
}