mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 13:04:08 +00:00
Revert "fix(coding-agent): handle npm on Windows with shell fallback fixes #1220"
This reverts commit 895b85636a.
This commit is contained in:
parent
3297a47c40
commit
1fe73ad423
1 changed files with 4 additions and 24 deletions
|
|
@ -1595,31 +1595,12 @@ export class DefaultPackageManager implements PackageManager {
|
|||
};
|
||||
}
|
||||
|
||||
private resolveCommand(command: string): { command: string; shell: boolean } {
|
||||
if (process.platform === "win32" && command === "npm") {
|
||||
const whereResult = spawnSync("where", [command], { encoding: "utf-8" });
|
||||
const resolved = whereResult.status === 0 ? (whereResult.stdout || "").split(/\r?\n/)[0] : "";
|
||||
const lower = resolved.toLowerCase();
|
||||
if (resolved) {
|
||||
if (lower.endsWith(".exe")) {
|
||||
return { command: resolved, shell: false };
|
||||
}
|
||||
if (lower.endsWith(".cmd") || lower.endsWith(".bat") || lower.endsWith(".ps1")) {
|
||||
return { command: resolved, shell: true };
|
||||
}
|
||||
}
|
||||
return { command, shell: true };
|
||||
}
|
||||
return { command, shell: process.platform === "win32" };
|
||||
}
|
||||
|
||||
private runCommand(command: string, args: string[], options?: { cwd?: string }): Promise<void> {
|
||||
const resolved = this.resolveCommand(command);
|
||||
return new Promise((resolvePromise, reject) => {
|
||||
const child = spawn(resolved.command, args, {
|
||||
const child = spawn(command, args, {
|
||||
cwd: options?.cwd,
|
||||
stdio: "inherit",
|
||||
shell: resolved.shell,
|
||||
shell: process.platform === "win32",
|
||||
});
|
||||
child.on("error", reject);
|
||||
child.on("exit", (code) => {
|
||||
|
|
@ -1633,11 +1614,10 @@ export class DefaultPackageManager implements PackageManager {
|
|||
}
|
||||
|
||||
private runCommandSync(command: string, args: string[]): string {
|
||||
const resolved = this.resolveCommand(command);
|
||||
const result = spawnSync(resolved.command, args, {
|
||||
const result = spawnSync(command, args, {
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
encoding: "utf-8",
|
||||
shell: resolved.shell,
|
||||
shell: process.platform === "win32",
|
||||
});
|
||||
if (result.status !== 0) {
|
||||
throw new Error(`Failed to run ${command} ${args.join(" ")}: ${result.stderr || result.stdout}`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue