-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
43 lines (31 loc) · 945 Bytes
/
index.js
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
var execSync = require('child_process').execSync;
var isLinux = require('os-family').linux;
var LIBC_TYPE = {
glibc: 'glibc',
musl: 'musl',
unknown: 'unknown'
};
var bits = ['x64', 'arm64', 'ppc64'].indexOf(process.arch) > -1 ? 64 : 32;
function getLddOutput () {
try {
return execSync('ldd --version', { stdio: 'pipe' }).toString().split('\n');
}
catch (e) {
var output = e.message.split('\n');
output.shift();
return output;
}
}
function getLibCType () {
var lddOutput = getLddOutput();
if (/glibc|gnu\s*libc/i.test(lddOutput[0]))
return LIBC_TYPE.glibc;
else if (/musl/i.test(lddOutput[0]))
return LIBC_TYPE.musl;
return LIBC_TYPE.unknown;
}
var libcType = isLinux ? getLibCType() : LIBC_TYPE.unknown;
exports.LIBC_TYPE = LIBC_TYPE;
exports.bits = bits;
exports.libcType = libcType;
exports.platform = libcType + '-' + bits;