mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-13 18:32:12 +03:00
38 lines
1.3 KiB
JavaScript
38 lines
1.3 KiB
JavaScript
/** Exact native-addon layout published by wreq-js 3.0.0. */
|
|
export const WREQ_JS_NATIVE_BINARY_NAMES = Object.freeze([
|
|
"wreq-js.darwin-arm64.node",
|
|
"wreq-js.darwin-x64.node",
|
|
"wreq-js.linux-arm64-gnu.node",
|
|
"wreq-js.linux-arm64-musl.node",
|
|
"wreq-js.linux-x64-gnu.node",
|
|
"wreq-js.linux-x64-musl.node",
|
|
"wreq-js.win32-x64-msvc.node",
|
|
]);
|
|
|
|
/** Detect the C library used by the current Linux runtime. */
|
|
export function detectRuntimeLibc() {
|
|
if (process.platform !== "linux") return undefined;
|
|
try {
|
|
const report = process.report?.getReport();
|
|
return report?.header?.glibcVersionRuntime ? "gnu" : "musl";
|
|
} catch {
|
|
return "musl";
|
|
}
|
|
}
|
|
|
|
/** Resolve the exact addon filename that wreq-js 3.0.0 will load. */
|
|
export function resolveWreqJsNativeBinaryName({ platform, arch, libc }) {
|
|
if (platform === "darwin" && (arch === "arm64" || arch === "x64")) {
|
|
return `wreq-js.darwin-${arch}.node`;
|
|
}
|
|
if (platform === "linux" && (arch === "arm64" || arch === "x64")) {
|
|
const linuxLibc = libc ?? detectRuntimeLibc();
|
|
if (linuxLibc !== "gnu" && linuxLibc !== "musl") return null;
|
|
return `wreq-js.linux-${arch}-${linuxLibc}.node`;
|
|
}
|
|
if (platform === "win32" && arch === "x64") {
|
|
return "wreq-js.win32-x64-msvc.node";
|
|
}
|
|
return null;
|
|
}
|