MCPcopy Create free account
hub / github.com/WiseLibs/better-sqlite3 / isLinuxMusl

Function isLinuxMusl

lib/binding.js:52–73  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

50}
51
52function isLinuxMusl() {
53 if (process.platform !== 'linux') {
54 return false;
55 }
56
57 // Look at which libc loader is mapped into this process (See #1517, #1527).
58 try {
59 const maps = fs.readFileSync('/proc/self/maps', 'latin1');
60 if (/\/ld-musl-[^/\s]*\.so/.test(maps)) return true;
61 if (/\/(?:ld-linux[^/\s]*|libc)\.so\.\d/.test(maps)) return false;
62 } catch {}
63
64 // Fallback detection (less reliable, potentially slow).
65 const { report } = process;
66 const previousExcludeNetwork = report.excludeNetwork;
67 report.excludeNetwork = true;
68 try {
69 return !report.getReport().header.glibcVersionRuntime;
70 } finally {
71 report.excludeNetwork = previousExcludeNetwork;
72 }
73}
74
75exports.getBinding = getBinding;
76exports.getPrebuildPath = getPrebuildPath;

Callers 1

getPrebuildPathFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected