CLI: expand versioned node argv handling
This commit is contained in:
committed by
Gustavo Madeira Santana
parent
c95072fc26
commit
566c9982b3
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user