2026-02-26 22:38:57 +01:00
|
|
|
const NODE_VERSIONED_PATTERN = /^node(?:-\d+|\d+)(?:\.\d+)*(?:\.exe)?$/;
|
|
|
|
|
|
|
|
|
|
function normalizeRuntimeBasename(execPath: string): string {
|
|
|
|
|
const trimmed = execPath.trim().replace(/^["']|["']$/g, "");
|
|
|
|
|
const lastSlash = Math.max(trimmed.lastIndexOf("/"), trimmed.lastIndexOf("\\"));
|
|
|
|
|
const basename = lastSlash === -1 ? trimmed : trimmed.slice(lastSlash + 1);
|
|
|
|
|
return basename.toLowerCase();
|
|
|
|
|
}
|
2026-02-22 21:18:30 +00:00
|
|
|
|
|
|
|
|
export function isNodeRuntime(execPath: string): boolean {
|
2026-02-26 22:38:57 +01:00
|
|
|
const base = normalizeRuntimeBasename(execPath);
|
|
|
|
|
return (
|
|
|
|
|
base === "node" ||
|
|
|
|
|
base === "node.exe" ||
|
|
|
|
|
base === "nodejs" ||
|
|
|
|
|
base === "nodejs.exe" ||
|
|
|
|
|
NODE_VERSIONED_PATTERN.test(base)
|
|
|
|
|
);
|
2026-02-22 21:18:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function isBunRuntime(execPath: string): boolean {
|
2026-02-26 22:38:57 +01:00
|
|
|
const base = normalizeRuntimeBasename(execPath);
|
2026-02-22 21:18:30 +00:00
|
|
|
return base === "bun" || base === "bun.exe";
|
|
|
|
|
}
|