fix(coding-agent): spawn Windows npm shims directly

closes #4623
This commit is contained in:
Armin Ronacher
2026-05-18 00:21:09 +02:00
parent ed3904ddd3
commit 6b872be2b9
6 changed files with 156 additions and 29 deletions

View File

@@ -28,7 +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 { resolveSpawnCommand } 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";
@@ -2408,11 +2408,12 @@ export class DefaultPackageManager implements PackageManager {
}
private spawnCommand(command: string, args: string[], options?: { cwd?: string }): ChildProcess {
return spawn(command, args, {
const env = getEnv();
const resolved = resolveSpawnCommand(command, args, { env });
return spawn(resolved.command, resolved.args, {
cwd: options?.cwd,
stdio: isStdoutTakenOver() ? ["ignore", 2, 2] : "inherit",
shell: shouldUseWindowsShell(command),
env: getEnv(),
env,
});
}
@@ -2422,11 +2423,12 @@ export class DefaultPackageManager implements PackageManager {
options?: { cwd?: string; env?: Record<string, string> },
): ChildProcessByStdio<null, Readable, Readable> {
const baseEnv = getEnv();
return spawn(command, args, {
const env = options?.env ? { ...baseEnv, ...options.env } : baseEnv;
const resolved = resolveSpawnCommand(command, args, { env });
return spawn(resolved.command, resolved.args, {
cwd: options?.cwd,
stdio: ["ignore", "pipe", "pipe"],
shell: shouldUseWindowsShell(command),
env: options?.env ? { ...baseEnv, ...options.env } : baseEnv,
env,
});
}
@@ -2489,11 +2491,12 @@ export class DefaultPackageManager implements PackageManager {
}
private runCommandSync(command: string, args: string[]): string {
const result = spawnSync(command, args, {
const env = getEnv();
const resolved = resolveSpawnCommand(command, args, { env });
const result = spawnSync(resolved.command, resolved.args, {
stdio: ["ignore", "pipe", "pipe"],
encoding: "utf-8",
shell: shouldUseWindowsShell(command),
env: getEnv(),
env,
});
if (result.error || result.status !== 0) {
throw new Error(