-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplatform.ts
More file actions
51 lines (41 loc) · 1018 Bytes
/
platform.ts
File metadata and controls
51 lines (41 loc) · 1018 Bytes
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
/** @fileoverview Platform detection and OS-specific constants. */
import { getNodeOs } from '../node/os'
/**
* CPU architecture type.
*/
export type Arch = NodeJS.Architecture
/**
* Linux libc variant.
*/
export type Libc = 'glibc' | 'musl'
/**
* Operating system platform type.
*/
export type Platform = NodeJS.Platform
let _arch: Arch | undefined
/**
* Get the current CPU architecture (memoized).
*/
export function getArch(): Arch {
if (_arch === undefined) {
_arch = getNodeOs().arch()
}
return _arch
}
let _platform: Platform | undefined
/**
* Get the current platform (memoized).
*/
export function getPlatform(): Platform {
if (_platform === undefined) {
_platform = getNodeOs().platform()
}
return _platform
}
// Platform detection (memoized at module load).
export const DARWIN = getPlatform() === 'darwin'
export const WIN32 = getPlatform() === 'win32'
// File permission modes.
export const S_IXUSR = 0o100
export const S_IXGRP = 0o010
export const S_IXOTH = 0o001