UNPKG

3.31 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.knownArchs = exports.targetArchs = exports.hostArch = exports.knownPlatforms = exports.hostPlatform = exports.hostAbi = exports.toFancyArch = exports.toFancyPlatform = exports.isValidNodeRange = exports.abiToNodeRange = void 0;
4var child_process_1 = require("child_process");
5function getHostAbi() {
6 return "m" + process.versions.modules;
7}
8function abiToNodeRange(abi) {
9 if (/^m?14/.test(abi))
10 return 'node0.12';
11 if (/^m?46/.test(abi))
12 return 'node4';
13 if (/^m?47/.test(abi))
14 return 'node5';
15 if (/^m?48/.test(abi))
16 return 'node6';
17 if (/^m?51/.test(abi))
18 return 'node7';
19 if (/^m?57/.test(abi))
20 return 'node8';
21 if (/^m?59/.test(abi))
22 return 'node9';
23 if (/^m?64/.test(abi))
24 return 'node10';
25 if (/^m?67/.test(abi))
26 return 'node11';
27 if (/^m?72/.test(abi))
28 return 'node12';
29 if (/^m?79/.test(abi))
30 return 'node13';
31 if (/^m?83/.test(abi))
32 return 'node14';
33 return abi;
34}
35exports.abiToNodeRange = abiToNodeRange;
36function isValidNodeRange(nodeRange) {
37 if (nodeRange === 'latest')
38 return true;
39 if (!/^node/.test(nodeRange))
40 return false;
41 return true;
42}
43exports.isValidNodeRange = isValidNodeRange;
44function toFancyPlatform(platform) {
45 if (platform === 'darwin')
46 return 'macos';
47 if (platform === 'lin')
48 return 'linux';
49 if (platform === 'mac')
50 return 'macos';
51 if (platform === 'osx')
52 return 'macos';
53 if (platform === 'win32')
54 return 'win';
55 if (platform === 'windows')
56 return 'win';
57 return platform;
58}
59exports.toFancyPlatform = toFancyPlatform;
60function detectAlpine() {
61 var platform = process.platform;
62 if (platform !== 'linux') {
63 return false;
64 }
65 // https://github.com/sass/node-sass/issues/1589#issuecomment-265292579
66 var ldd = child_process_1.spawnSync('ldd').stderr.toString();
67 if (/\bmusl\b/.test(ldd)) {
68 return true;
69 }
70 var lddNode = child_process_1.spawnSync('ldd', [process.execPath]).stdout.toString();
71 return /\bmusl\b/.test(lddNode);
72}
73var isAlpine = detectAlpine();
74function getHostPlatform() {
75 var platform = process.platform;
76 if (isAlpine) {
77 return 'alpine';
78 }
79 return toFancyPlatform(platform);
80}
81function getKnownPlatforms() {
82 return ['alpine', 'freebsd', 'linux', 'linuxstatic', 'macos', 'win'];
83}
84function toFancyArch(arch) {
85 if (arch === 'arm')
86 return 'armv7';
87 if (arch === 'ia32')
88 return 'x86';
89 if (arch === 'x86_64')
90 return 'x64';
91 return arch;
92}
93exports.toFancyArch = toFancyArch;
94function getHostArch() {
95 return toFancyArch(process.arch);
96}
97function getTargetArchs() {
98 var arch = getHostArch();
99 if (arch === 'x64') {
100 return ['x64', 'x86'];
101 }
102 return [arch];
103}
104function getKnownArchs() {
105 return ['x64', 'x86', 'armv7', 'arm64', 'ppc64', 's390x'];
106}
107exports.hostAbi = getHostAbi();
108exports.hostPlatform = getHostPlatform();
109exports.knownPlatforms = getKnownPlatforms();
110exports.hostArch = getHostArch();
111exports.targetArchs = getTargetArchs();
112exports.knownArchs = getKnownArchs();
113//# sourceMappingURL=system.js.map
\No newline at end of file