"use strict";
const ARCH_MAP = {
x64: "amd64",
amd64: "amd64",
arm64: "arm64",
};
const PLATFORM_MAP = {
linux: "linux",
darwin: "darwin",
win32: "windows",
};
* Resolve the bundled binary file name for the current platform/arch.
* Returns e.g. "gc-linux-amd64" or "gc-windows-amd64.exe".
* Throws when the platform/arch is unsupported (no bundled binary exists).
*/
function resolveBinaryName(platform, arch) {
const p = PLATFORM_MAP[platform];
const a = ARCH_MAP[arch];
if (!p || !a || (p === "windows" && a !== "amd64")) {
throw new Error(
`unsupported platform/arch: ${platform}/${arch}; ` +
`supported: linux/x64, linux/arm64, darwin/x64, darwin/arm64, win32/x64`
);
}
const name = `gc-${p}-${a}`;
return p === "windows" ? `${name}.exe` : name;
}
* True when the resolved binary is bundled (i.e. the platform/arch combo is
* one we ship). Used by install to decide whether to fall back.
*/
function isSupported(platform, arch) {
try {
resolveBinaryName(platform, arch);
return true;
} catch {
return false;
}
}
module.exports = { resolveBinaryName, isSupported, ARCH_MAP, PLATFORM_MAP };