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

@@ -3,7 +3,7 @@ import { accessSync, constants, existsSync, readFileSync, realpathSync } from "f
import { homedir } from "os";
import { basename, dirname, join, resolve, sep, win32 } from "path";
import { fileURLToPath } from "url";
import { shouldUseWindowsShell } from "./utils/child-process.js";
import { resolveSpawnCommand } from "./utils/child-process.js";
// =============================================================================
// Package Detection
@@ -151,10 +151,18 @@ function readCommandOutput(
args: string[],
options: { requireSuccess?: boolean } = {},
): string | undefined {
const result = spawnSync(command, args, {
let resolved: ReturnType<typeof resolveSpawnCommand>;
try {
resolved = resolveSpawnCommand(command, args);
} catch (error) {
if (options.requireSuccess) {
throw error;
}
return undefined;
}
const result = spawnSync(resolved.command, resolved.args, {
encoding: "utf-8",
stdio: ["ignore", "pipe", "pipe"],
shell: shouldUseWindowsShell(command),
});
if (result.status === 0) return result.stdout.trim() || undefined;
if (options.requireSuccess) {