mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-20 17:02:11 +00:00
fix(coding-agent): use shell execution for spawn on Windows
fixes #1220
This commit is contained in:
parent
91481a1e63
commit
ffb647cece
2 changed files with 11 additions and 11 deletions
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed Windows package installs regression by using shell execution instead of `.cmd` resolution ([#1220](https://github.com/badlogic/pi-mono/issues/1220))
|
||||||
|
|
||||||
## [0.51.4] - 2026-02-03
|
## [0.51.4] - 2026-02-03
|
||||||
|
|
||||||
### New Features
|
### New Features
|
||||||
|
|
|
||||||
|
|
@ -1595,19 +1595,12 @@ export class DefaultPackageManager implements PackageManager {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private resolveCommand(command: string): string {
|
|
||||||
if (process.platform === "win32" && command === "npm") {
|
|
||||||
return "npm.cmd";
|
|
||||||
}
|
|
||||||
return command;
|
|
||||||
}
|
|
||||||
|
|
||||||
private runCommand(command: string, args: string[], options?: { cwd?: string }): Promise<void> {
|
private runCommand(command: string, args: string[], options?: { cwd?: string }): Promise<void> {
|
||||||
const resolvedCommand = this.resolveCommand(command);
|
|
||||||
return new Promise((resolvePromise, reject) => {
|
return new Promise((resolvePromise, reject) => {
|
||||||
const child = spawn(resolvedCommand, args, {
|
const child = spawn(command, args, {
|
||||||
cwd: options?.cwd,
|
cwd: options?.cwd,
|
||||||
stdio: "inherit",
|
stdio: "inherit",
|
||||||
|
shell: process.platform === "win32",
|
||||||
});
|
});
|
||||||
child.on("error", reject);
|
child.on("error", reject);
|
||||||
child.on("exit", (code) => {
|
child.on("exit", (code) => {
|
||||||
|
|
@ -1621,8 +1614,11 @@ export class DefaultPackageManager implements PackageManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private runCommandSync(command: string, args: string[]): string {
|
private runCommandSync(command: string, args: string[]): string {
|
||||||
const resolvedCommand = this.resolveCommand(command);
|
const result = spawnSync(command, args, {
|
||||||
const result = spawnSync(resolvedCommand, args, { stdio: ["ignore", "pipe", "pipe"], encoding: "utf-8" });
|
stdio: ["ignore", "pipe", "pipe"],
|
||||||
|
encoding: "utf-8",
|
||||||
|
shell: process.platform === "win32",
|
||||||
|
});
|
||||||
if (result.status !== 0) {
|
if (result.status !== 0) {
|
||||||
throw new Error(`Failed to run ${command} ${args.join(" ")}: ${result.stderr || result.stdout}`);
|
throw new Error(`Failed to run ${command} ${args.join(" ")}: ${result.stderr || result.stdout}`);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue