CLI: fix Windows node argv stripping

This commit is contained in:
Tak hoffman 2026-01-23 23:58:03 -06:00 committed by Peter Steinberger
parent ae48066d28
commit d3df691684

View File

@ -1,3 +1,4 @@
import fs from "node:fs";
import path from "node:path";
import process from "node:process";
import { fileURLToPath } from "node:url";
@ -82,13 +83,16 @@ function stripWindowsNodeExec(argv: string[]): string[] {
const execBase = path.basename(execPath).toLowerCase();
const isExecPath = (value: string | undefined): boolean => {
if (!value) return false;
const lower = normalizeCandidate(value).toLowerCase();
const normalized = normalizeCandidate(value);
if (!normalized) return false;
const lower = normalized.toLowerCase();
return (
lower === execPathLower ||
path.basename(lower) === execBase ||
lower.endsWith("\\node.exe") ||
lower.endsWith("/node.exe") ||
lower.includes("node.exe")
lower.includes("node.exe") ||
(path.basename(lower) === "node.exe" && fs.existsSync(normalized))
);
};
const filtered = argv.filter((arg, index) => index === 0 || !isExecPath(arg));