refactor: share windows command shim resolution

This commit is contained in:
Peter Steinberger
2026-03-10 20:46:32 +00:00
parent 1df78202b9
commit 344b2286aa
4 changed files with 64 additions and 25 deletions

View File

@@ -7,6 +7,7 @@ import { danger, shouldLogVerbose } from "../globals.js";
import { markOpenClawExecEnv } from "../infra/openclaw-exec-env.js";
import { logDebug, logError } from "../logger.js";
import { resolveCommandStdio } from "./spawn-utils.js";
import { resolveWindowsCommandShim } from "./windows-command.js";
const execFileAsync = promisify(execFile);
@@ -76,19 +77,10 @@ function resolveNpmArgvForWindows(argv: string[]): string[] | null {
* are handled by resolveNpmArgvForWindows to avoid spawn EINVAL (no direct .cmd).
*/
function resolveCommand(command: string): string {
if (process.platform !== "win32") {
return command;
}
const basename = path.basename(command).toLowerCase();
const ext = path.extname(basename);
if (ext) {
return command;
}
const cmdCommands = ["pnpm", "yarn"];
if (cmdCommands.includes(basename)) {
return `${command}.cmd`;
}
return command;
return resolveWindowsCommandShim({
command,
cmdCommands: ["pnpm", "yarn"],
});
}
export function shouldSpawnWithShell(params: {