-
Notifications
You must be signed in to change notification settings - Fork 494
/
system.ts
44 lines (37 loc) · 1021 Bytes
/
system.ts
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
import os from 'os';
export function getPlatform(): string {
// darwin and linux match already
// freebsd not supported yet but future proofed.
// 'aix', 'darwin', 'freebsd', 'linux', 'openbsd', 'sunos', and 'win32'
let plat: string = os.platform();
// wants 'darwin', 'freebsd', 'linux', 'windows'
if (plat === 'win32') {
plat = 'windows';
}
return plat;
}
export function getArch(arch: string): string {
// 'arm', 'arm64', 'ia32', 'mips', 'mipsel', 'ppc', 'ppc64', 's390', 's390x', 'x32', and 'x64'.
// wants amd64, 386, arm64, armv61, ppc641e, s390x
// currently not supported by runner but future proofed mapping
let endianness: string = os.endianness();
switch (arch) {
case 'x64':
arch = 'amd64';
break;
case 'ppc64':
if (endianness == 'LE') {
arch = 'ppc64le';
} else {
arch = 'ppc64';
}
break;
case 'x32':
arch = '386';
break;
case 'arm':
arch = 'armv6l';
break;
}
return arch;
}