detect-libc
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -15,2 +15,8 @@ 'use strict'; | ||
if (!spawnSync) { | ||
spawnSync = function () { | ||
return { status: 126, stdout: '', stderr: '' }; | ||
}; | ||
} | ||
function contains (needle) { | ||
@@ -28,4 +34,5 @@ return function (haystack) { | ||
var version = ''; | ||
var method = ''; | ||
if (spawnSync && platform === 'linux') { | ||
if (platform === 'linux') { | ||
// Try getconf | ||
@@ -36,2 +43,3 @@ var glibc = spawnSync('getconf', ['GNU_LIBC_VERSION'], spawnOptions); | ||
version = glibc.stdout.trim().split(' ')[1]; | ||
method = 'getconf'; | ||
} else { | ||
@@ -43,5 +51,7 @@ // Try ldd | ||
version = versionFromMuslLdd(ldd.stdout); | ||
method = 'ldd'; | ||
} else if (ldd.status === 1 && ldd.stderr.indexOf(MUSL) !== -1) { | ||
family = MUSL; | ||
version = versionFromMuslLdd(ldd.stderr); | ||
method = 'ldd'; | ||
} else { | ||
@@ -51,8 +61,15 @@ // Try filesystem (family only) | ||
var lib = readdirSync('/lib'); | ||
var usrSbin = readdirSync('/usr/sbin'); | ||
if (lib.some(contains('-linux-gnu'))) { | ||
family = GLIBC; | ||
method = 'filesystem'; | ||
} else if (lib.some(contains('libc.musl-'))) { | ||
family = MUSL; | ||
method = 'filesystem'; | ||
} else if (lib.some(contains('ld-musl-'))) { | ||
family = MUSL; | ||
method = 'filesystem'; | ||
} else if (usrSbin.some(contains('glibc'))) { | ||
family = GLIBC; | ||
method = 'filesystem'; | ||
} | ||
@@ -71,3 +88,4 @@ } catch (e) {} | ||
version: version, | ||
method: method, | ||
isNonGlibcLinux: isNonGlibcLinux | ||
}; |
{ | ||
"name": "detect-libc", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Node.js module to detect the C standard library (libc) implementation family and version", | ||
@@ -22,2 +22,5 @@ "main": "lib/detect-libc.js", | ||
"author": "Lovell Fuller <npm@lovell.info>", | ||
"contributors": [ | ||
"Niklas Salmoukas <niklas@salmoukas.com>" | ||
], | ||
"license": "Apache-2.0", | ||
@@ -24,0 +27,0 @@ "devDependencies": { |
@@ -35,5 +35,2 @@ # detect-libc | ||
This feature will always return `false` for `isNonGlibcLinux` | ||
on versions of Node prior to v0.12 as `spawnSync` is unavailable. | ||
### detect-libc command line tool | ||
@@ -47,3 +44,3 @@ | ||
This feature requires `spawnSync` provided by Node v0.12+. | ||
The command line feature requires `spawnSync` provided by Node v0.12+. | ||
@@ -62,3 +59,3 @@ ```sh | ||
"dependencies": { | ||
"detect-libc": "^0.2.0", | ||
"detect-libc": "^1.0.2", | ||
"prebuild-install": "^2.2.0" | ||
@@ -65,0 +62,0 @@ }, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17116
88
79