-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindows.ts
More file actions
82 lines (77 loc) · 2.08 KB
/
windows.ts
File metadata and controls
82 lines (77 loc) · 2.08 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/**
* @fileoverview Windows environment variable getters.
* Provides access to Windows-specific user directory paths.
*/
import { getEnvValue } from './rewire'
/**
* APPDATA environment variable.
* Points to the Application Data directory on Windows.
*
* @returns The Windows AppData roaming directory, or `undefined` if not set
*
* @example
* ```typescript
* import { getAppdata } from '@socketsecurity/lib/env/windows'
*
* const appdata = getAppdata()
* // e.g. 'C:\\Users\\Public\\AppData\\Roaming' or undefined
* ```
*/
/*@__NO_SIDE_EFFECTS__*/
export function getAppdata(): string | undefined {
return getEnvValue('APPDATA')
}
/**
* COMSPEC environment variable.
* Points to the Windows command processor (typically cmd.exe).
*
* @returns The path to the command processor, or `undefined` if not set
*
* @example
* ```typescript
* import { getComspec } from '@socketsecurity/lib/env/windows'
*
* const comspec = getComspec()
* // e.g. 'C:\\Windows\\system32\\cmd.exe' or undefined
* ```
*/
/*@__NO_SIDE_EFFECTS__*/
export function getComspec(): string | undefined {
return getEnvValue('COMSPEC')
}
/**
* LOCALAPPDATA environment variable.
* Points to the Local Application Data directory on Windows.
*
* @returns The Windows local AppData directory, or `undefined` if not set
*
* @example
* ```typescript
* import { getLocalappdata } from '@socketsecurity/lib/env/windows'
*
* const localAppdata = getLocalappdata()
* // e.g. 'C:\\Users\\Public\\AppData\\Local' or undefined
* ```
*/
/*@__NO_SIDE_EFFECTS__*/
export function getLocalappdata(): string | undefined {
return getEnvValue('LOCALAPPDATA')
}
/**
* USERPROFILE environment variable.
* Windows user home directory path.
*
* @returns The Windows user profile directory, or `undefined` if not set
*
* @example
* ```typescript
* import { getUserprofile } from '@socketsecurity/lib/env/windows'
*
* const userprofile = getUserprofile()
* // e.g. 'C:\\Users\\Public' or undefined
* ```
*/
/*@__NO_SIDE_EFFECTS__*/
export function getUserprofile(): string | undefined {
return getEnvValue('USERPROFILE')
}