CLI: fix Windows node argv stripping (#1564)

Co-authored-by: Tak hoffman <takayukihoffman@gmail.com>
This commit is contained in:
Tak Hoffman
2026-01-24 01:10:40 -06:00
committed by GitHub
parent 6a60d47c53
commit 8f4426052c

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));