fix(coding-agent): repair self-update detection

Fixes #3942
Fixes #3980
Fixes #3922
This commit is contained in:
Armin Ronacher
2026-04-30 19:10:06 +02:00
parent def47ece92
commit ade08de14c
6 changed files with 349 additions and 117 deletions

View File

@@ -28,6 +28,7 @@ import { globSync } from "glob";
import ignore from "ignore";
import { minimatch } from "minimatch";
import { CONFIG_DIR_NAME } from "../config.js";
import { shouldUseWindowsShell } from "../utils/child-process.js";
import { type GitSource, parseGitUrl } from "../utils/git.js";
import { canonicalizePath, isLocalPath } from "../utils/paths.js";
import { isStdoutTakenOver } from "./output-guard.js";
@@ -2329,28 +2330,11 @@ export class DefaultPackageManager implements PackageManager {
};
}
private shouldUseWindowsShell(command: string): boolean {
if (process.platform !== "win32") {
return false;
}
const commandName = basename(command).toLowerCase();
return (
commandName === "npm" ||
commandName === "npx" ||
commandName === "pnpm" ||
commandName === "yarn" ||
commandName === "yarnpkg" ||
commandName === "corepack" ||
commandName.endsWith(".cmd") ||
commandName.endsWith(".bat")
);
}
private spawnCommand(command: string, args: string[], options?: { cwd?: string }): ChildProcess {
return spawn(command, args, {
cwd: options?.cwd,
stdio: isStdoutTakenOver() ? ["ignore", 2, 2] : "inherit",
shell: this.shouldUseWindowsShell(command),
shell: shouldUseWindowsShell(command),
env: getEnv(),
});
}
@@ -2364,7 +2348,7 @@ export class DefaultPackageManager implements PackageManager {
return spawn(command, args, {
cwd: options?.cwd,
stdio: ["ignore", "pipe", "pipe"],
shell: this.shouldUseWindowsShell(command),
shell: shouldUseWindowsShell(command),
env: options?.env ? { ...baseEnv, ...options.env } : baseEnv,
});
}
@@ -2431,7 +2415,7 @@ export class DefaultPackageManager implements PackageManager {
const result = spawnSync(command, args, {
stdio: ["ignore", "pipe", "pipe"],
encoding: "utf-8",
shell: this.shouldUseWindowsShell(command),
shell: shouldUseWindowsShell(command),
env: getEnv(),
});
if (result.error || result.status !== 0) {