-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.js
More file actions
39 lines (29 loc) · 982 Bytes
/
Copy pathinstall.js
File metadata and controls
39 lines (29 loc) · 982 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
import { getLogger, install } from '@node-3d/addon-tools';
const prefix = 'https://github.com/node-3d/uv-loop/releases/download';
const logger = getLogger('uv-loop');
const version = '0.1.0';
const NODE_VERSION_MIN = 22;
const NODE_VERSION_MAX = 26;
const runtimeNodeMajor = Number.parseInt(process.versions.node.split('.')[0] ?? '', 10);
const getBinaryNodeMajor = (nodeMajor) => {
if (!Number.isSafeInteger(nodeMajor)) {
return NODE_VERSION_MAX;
}
if (nodeMajor < NODE_VERSION_MIN) {
return NODE_VERSION_MIN;
}
if (nodeMajor > NODE_VERSION_MAX) {
return NODE_VERSION_MAX;
}
if (nodeMajor % 2 === 1) {
return nodeMajor - 1;
}
return nodeMajor;
};
const binaryNodeMajor = getBinaryNodeMajor(runtimeNodeMajor);
if (binaryNodeMajor !== runtimeNodeMajor) {
logger.warn(
`[uv-loop] Node.js ${process.versions.node} does not have a dedicated binary; using Node.js ${binaryNodeMajor} binary.`,
);
}
await install(`${prefix}/${version}-${binaryNodeMajor}`);