Skip to content

Commit

Permalink
Detect libc with a more specific string
Browse files Browse the repository at this point in the history
  • Loading branch information
dstaley committed Mar 18, 2024
1 parent f39eac2 commit 1fefe16
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 35 deletions.
2 changes: 1 addition & 1 deletion lib/detect-libc.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const getFamilyFromLddContent = (content) => {
if (content.includes('musl')) {
return MUSL;
}
if (content.match(/libc/i)) {
if (content.includes('GNU C Library')) {
return GLIBC;
}
return null;
Expand Down
36 changes: 2 additions & 34 deletions test/unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,7 @@ test('linux - glibc family detected via ldd', async (t) => {
isLinux: () => true
},
'./filesystem': {
readFile: () => Promise.resolve('bunch-of-text GLIBC')
}
});

t.is(await libc.family(), libc.GLIBC);
t.false(await libc.isNonGlibcLinux());
});

test('linux - glibc family detected via ldd (libc)', async (t) => {
t.plan(2);

const libc = proxyquire('../', {
'./process': {
isLinux: () => true
},
'./filesystem': {
readFile: () => Promise.resolve('TEXTDOMAIN=libc')
readFile: () => Promise.resolve('# This file is part of the GNU C Library.')
}
});

Expand All @@ -90,23 +74,7 @@ test('linux - glibc familySync detected via ldd', async (t) => {
isLinux: () => true
},
'./filesystem': {
readFileSync: () => 'bunch-of-text GLIBC'
}
});

t.is(libc.familySync(), libc.GLIBC);
t.false(libc.isNonGlibcLinuxSync());
});

test('linux - glibc familySync detected via ldd (libc)', async (t) => {
t.plan(2);

const libc = proxyquire('../', {
'./process': {
isLinux: () => true
},
'./filesystem': {
readFileSync: () => 'TEXTDOMAIN=libc'
readFileSync: () => '# The GNU C Library is free software; you can redistribute it and/or'
}
});

Expand Down

0 comments on commit 1fefe16

Please sign in to comment.