CLI: expand versioned node argv handling

This commit is contained in:
Gustavo Madeira Santana
2026-01-26 20:29:15 -05:00
committed by Gustavo Madeira Santana
parent c95072fc26
commit 566c9982b3
2 changed files with 59 additions and 6 deletions

View File

@@ -96,16 +96,27 @@ export function buildParseArgv(params: {
: baseArgv;
const executable = (normalizedArgv[0]?.split(/[/\\]/).pop() ?? "").toLowerCase();
const looksLikeNode =
normalizedArgv.length >= 2 &&
(executable === "node" ||
executable === "node.exe" ||
executable.startsWith("node-") ||
executable === "bun" ||
executable === "bun.exe");
normalizedArgv.length >= 2 && (isNodeExecutable(executable) || isBunExecutable(executable));
if (looksLikeNode) return normalizedArgv;
return ["node", programName || "clawdbot", ...normalizedArgv];
}
const nodeExecutablePattern = /^node-\d+(?:\.\d+)*(?:\.exe)?$/;
function isNodeExecutable(executable: string): boolean {
return (
executable === "node" ||
executable === "node.exe" ||
executable === "nodejs" ||
executable === "nodejs.exe" ||
nodeExecutablePattern.test(executable)
);
}
function isBunExecutable(executable: string): boolean {
return executable === "bun" || executable === "bun.exe";
}
export function shouldMigrateStateFromPath(path: string[]): boolean {
if (path.length === 0) return true;
const [primary, secondary] = path;