Skip to content

Commit ed831b9

Browse files
committed
feat: allow checkPlatform to override execution libc
1 parent 4fc835c commit ed831b9

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

lib/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ const checkPlatform = (target, force = false, environment = {}) => {
3636
let libcFamily = null
3737
if (target.libc) {
3838
// libc checks only work in linux, any value is a failure if we aren't
39-
if (platform !== 'linux') {
39+
if (environment.libc) {
40+
libcOk = checkList(environment.libc, target.libc)
41+
} else if (platform !== 'linux') {
4042
libcOk = false
4143
} else {
4244
const report = process.report.getReport()

test/check-platform.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ t.test('nothing wrong with overridden cpu', async t =>
5959
cpu: 'enten-cpu',
6060
}))
6161

62+
t.test('nothing wrong with overridden libc', async t =>
63+
checkPlatform({
64+
cpu: 'enten-cpu',
65+
libc: 'enten-libc',
66+
}, false, {
67+
cpu: 'enten-cpu',
68+
libc: 'enten-libc',
69+
}))
70+
6271
t.test('wrong os with overridden os', async t =>
6372
t.throws(() => checkPlatform({
6473
cpu: 'any',
@@ -75,6 +84,15 @@ t.test('wrong cpu with overridden cpu', async t =>
7584
cpu: 'another-cpu',
7685
}), { code: 'EBADPLATFORM' }))
7786

87+
t.test('wrong libc with overridden libc', async t =>
88+
t.throws(() => checkPlatform({
89+
cpu: 'enten-cpu',
90+
os: 'any',
91+
libc: 'enten-libc',
92+
}, false, {
93+
libc: 'another-libc',
94+
}), { code: 'EBADPLATFORM' }))
95+
7896
t.test('libc', (t) => {
7997
let PLATFORM = ''
8098

0 commit comments

Comments
 (0)