forked from microsoft/os-proxy-resolver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplatform.js
More file actions
34 lines (30 loc) · 836 Bytes
/
Copy pathplatform.js
File metadata and controls
34 lines (30 loc) · 836 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
'use strict';
const fs = require('fs');
function getLinuxLibc(report = process.report, versions = process.versions, readFile = fs.readFileSync) {
try {
if (report?.getReport?.().header?.glibcVersionRuntime) {
return 'glibc';
}
} catch {
// Reports can be disabled by the Node host.
}
if (versions?.musl) {
return 'musl';
}
if (versions?.glibc) {
return 'glibc';
}
try {
return readFile('/usr/bin/ldd', 'utf8').includes('musl') ? 'musl' : 'glibc';
} catch {
return 'glibc';
}
}
function getPlatformPackage(platform = process.platform, arch = process.arch, options = {}) {
if (platform !== 'linux') {
return `${platform}-${arch}`;
}
const libc = getLinuxLibc(options.report, options.versions, options.readFile);
return `${platform}-${arch}-${libc}`;
}
exports.getPlatformPackage = getPlatformPackage;