mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
parent
1c720d2850
commit
c60de42e98
2 changed files with 24 additions and 2 deletions
|
|
@ -96,12 +96,12 @@ export async function execCommand(
|
|||
}
|
||||
resolve({ stdout, stderr, code: code ?? 0, killed });
|
||||
})
|
||||
.catch((_err) => {
|
||||
.catch((error: Error) => {
|
||||
if (timeoutId) clearTimeout(timeoutId);
|
||||
if (options?.signal) {
|
||||
options.signal.removeEventListener("abort", killProcess);
|
||||
}
|
||||
resolve({ stdout, stderr, code: 1, killed });
|
||||
resolve({ stdout, stderr: stderr || error.message, code: 1, killed });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
22
packages/coding-agent/test/exec.test.ts
Normal file
22
packages/coding-agent/test/exec.test.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import { execCommand } from "../src/core/exec.ts";
|
||||
|
||||
describe("execCommand", () => {
|
||||
// Regression test for https://github.com/earendil-works/pi/issues/11085
|
||||
it("reports spawn errors in stderr", async () => {
|
||||
const result = await execCommand("pi-command-that-does-not-exist-11085", [], process.cwd());
|
||||
|
||||
expect(result).toMatchObject({
|
||||
code: 1,
|
||||
killed: false,
|
||||
stdout: "",
|
||||
});
|
||||
expect(result.stderr).toMatch(/ENOENT/);
|
||||
});
|
||||
|
||||
it("keeps stderr empty when a command exits silently", async () => {
|
||||
const result = await execCommand(process.execPath, ["-e", "process.exit(1)"], process.cwd());
|
||||
|
||||
expect(result).toEqual({ stdout: "", stderr: "", code: 1, killed: false });
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue