fix: strip noisy windows argv entries
This commit is contained in:
@@ -51,7 +51,11 @@ export async function runCli(argv: string[] = process.argv) {
|
|||||||
|
|
||||||
function stripWindowsNodeExec(argv: string[]): string[] {
|
function stripWindowsNodeExec(argv: string[]): string[] {
|
||||||
if (process.platform !== "win32") return argv;
|
if (process.platform !== "win32") return argv;
|
||||||
const normalizeArg = (value: string): string => value.replace(/^['"]+|['"]+$/g, "").trim();
|
const normalizeArg = (value: string): string =>
|
||||||
|
value
|
||||||
|
.replace(/[\u0000-\u001f\u007f]/g, "")
|
||||||
|
.replace(/^['"]+|['"]+$/g, "")
|
||||||
|
.trim();
|
||||||
const normalizeCandidate = (value: string): string =>
|
const normalizeCandidate = (value: string): string =>
|
||||||
normalizeArg(value).replace(/^\\\\\\?\\/, "");
|
normalizeArg(value).replace(/^\\\\\\?\\/, "");
|
||||||
const execPath = normalizeCandidate(process.execPath);
|
const execPath = normalizeCandidate(process.execPath);
|
||||||
@@ -64,7 +68,8 @@ function stripWindowsNodeExec(argv: string[]): string[] {
|
|||||||
lower === execPathLower ||
|
lower === execPathLower ||
|
||||||
path.basename(lower) === execBase ||
|
path.basename(lower) === execBase ||
|
||||||
lower.endsWith("\\node.exe") ||
|
lower.endsWith("\\node.exe") ||
|
||||||
lower.endsWith("/node.exe")
|
lower.endsWith("/node.exe") ||
|
||||||
|
lower.includes("node.exe")
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
const filtered = argv.filter((arg, index) => index === 0 || !isExecPath(arg));
|
const filtered = argv.filter((arg, index) => index === 0 || !isExecPath(arg));
|
||||||
|
|||||||
@@ -60,7 +60,11 @@ function ensureExperimentalWarningSuppressed(): boolean {
|
|||||||
function normalizeWindowsArgv(argv: string[]): string[] {
|
function normalizeWindowsArgv(argv: string[]): string[] {
|
||||||
if (process.platform !== "win32") return argv;
|
if (process.platform !== "win32") return argv;
|
||||||
if (argv.length < 3) return argv;
|
if (argv.length < 3) return argv;
|
||||||
const normalizeArg = (value: string): string => value.replace(/^['"]+|['"]+$/g, "").trim();
|
const normalizeArg = (value: string): string =>
|
||||||
|
value
|
||||||
|
.replace(/[\u0000-\u001f\u007f]/g, "")
|
||||||
|
.replace(/^['"]+|['"]+$/g, "")
|
||||||
|
.trim();
|
||||||
const normalizeCandidate = (value: string): string =>
|
const normalizeCandidate = (value: string): string =>
|
||||||
normalizeArg(value).replace(/^\\\\\\?\\/, "");
|
normalizeArg(value).replace(/^\\\\\\?\\/, "");
|
||||||
const execPath = normalizeCandidate(process.execPath);
|
const execPath = normalizeCandidate(process.execPath);
|
||||||
@@ -73,7 +77,8 @@ function normalizeWindowsArgv(argv: string[]): string[] {
|
|||||||
lower === execPathLower ||
|
lower === execPathLower ||
|
||||||
path.basename(lower) === execBase ||
|
path.basename(lower) === execBase ||
|
||||||
lower.endsWith("\\node.exe") ||
|
lower.endsWith("\\node.exe") ||
|
||||||
lower.endsWith("/node.exe")
|
lower.endsWith("/node.exe") ||
|
||||||
|
lower.includes("node.exe")
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
const arg1 = path.basename(argv[1] ?? "").toLowerCase();
|
const arg1 = path.basename(argv[1] ?? "").toLowerCase();
|
||||||
|
|||||||
Reference in New Issue
Block a user