CLI: fix Windows node argv stripping (#1564)
Co-authored-by: Tak hoffman <takayukihoffman@gmail.com>
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user