fix(coding-agent): repair self-update detection
Fixes #3942 Fixes #3980 Fixes #3922
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user