1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.knownArchs = exports.targetArchs = exports.hostArch = exports.knownPlatforms = exports.hostPlatform = exports.hostAbi = exports.toFancyArch = exports.toFancyPlatform = exports.isValidNodeRange = exports.abiToNodeRange = void 0;
|
4 | var child_process_1 = require("child_process");
|
5 | function getHostAbi() {
|
6 | return "m" + process.versions.modules;
|
7 | }
|
8 | function 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 | }
|
35 | exports.abiToNodeRange = abiToNodeRange;
|
36 | function isValidNodeRange(nodeRange) {
|
37 | if (nodeRange === 'latest')
|
38 | return true;
|
39 | if (!/^node/.test(nodeRange))
|
40 | return false;
|
41 | return true;
|
42 | }
|
43 | exports.isValidNodeRange = isValidNodeRange;
|
44 | function 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 | }
|
59 | exports.toFancyPlatform = toFancyPlatform;
|
60 | function detectAlpine() {
|
61 | var platform = process.platform;
|
62 | if (platform !== 'linux') {
|
63 | return false;
|
64 | }
|
65 |
|
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 | }
|
73 | var isAlpine = detectAlpine();
|
74 | function getHostPlatform() {
|
75 | var platform = process.platform;
|
76 | if (isAlpine) {
|
77 | return 'alpine';
|
78 | }
|
79 | return toFancyPlatform(platform);
|
80 | }
|
81 | function getKnownPlatforms() {
|
82 | return ['alpine', 'freebsd', 'linux', 'linuxstatic', 'macos', 'win'];
|
83 | }
|
84 | function 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 | }
|
93 | exports.toFancyArch = toFancyArch;
|
94 | function getHostArch() {
|
95 | return toFancyArch(process.arch);
|
96 | }
|
97 | function getTargetArchs() {
|
98 | var arch = getHostArch();
|
99 | if (arch === 'x64') {
|
100 | return ['x64', 'x86'];
|
101 | }
|
102 | return [arch];
|
103 | }
|
104 | function getKnownArchs() {
|
105 | return ['x64', 'x86', 'armv7', 'arm64', 'ppc64', 's390x'];
|
106 | }
|
107 | exports.hostAbi = getHostAbi();
|
108 | exports.hostPlatform = getHostPlatform();
|
109 | exports.knownPlatforms = getKnownPlatforms();
|
110 | exports.hostArch = getHostArch();
|
111 | exports.targetArchs = getTargetArchs();
|
112 | exports.knownArchs = getKnownArchs();
|
113 |
|
\ | No newline at end of file |