diff --git a/src/herdr.ts b/src/herdr.ts index bc80bfc..708aab5 100644 --- a/src/herdr.ts +++ b/src/herdr.ts @@ -76,7 +76,7 @@ export async function openSupervisorPane(input: LaunchSupervisorInput): Promise< await herdr(["pane", "run", paneId, supervisorCommand(input)]); return paneId; } catch (error) { - await herdr(["pane", "close", paneId]); + await closeSupervisorPane(paneId); throw error; } } diff --git a/test/herdr.test.ts b/test/herdr.test.ts index db5ef40..a95b71d 100644 --- a/test/herdr.test.ts +++ b/test/herdr.test.ts @@ -37,7 +37,7 @@ describe("supervisor pane command", () => { writeFileSync(bin, `#!/bin/sh if [ "$1" = "--version" ]; then echo "herdr 0.8.2"; exit 0; fi if [ "$1" = "pane" ] && [ "$2" = "split" ]; then echo '{"pane_id":"new-pane"}'; exit 0; fi -if [ "$1" = "pane" ] && [ "$2" = "run" ]; then echo '{}'; exit 0; fi +if [ "$1" = "pane" ] && [ "$2" = "run" ]; then if [ "$HERDR_SMOKE_RUN_FAIL" = "1" ]; then echo "run failed" >&2; exit 1; fi; echo '{}'; exit 0; fi if [ "$1" = "pane" ] && [ "$2" = "close" ]; then echo '{"error":{"code":"PANE_GONE"}}' >&2; exit 1; fi exit 2 `); @@ -47,6 +47,8 @@ exit 2 try { await expect(openSupervisorPane(input())).resolves.toBe("new-pane"); await expect(closeSupervisorPane("new-pane")).resolves.toBeUndefined(); + vi.stubEnv("HERDR_SMOKE_RUN_FAIL", "1"); + await expect(openSupervisorPane(input())).rejects.toThrow("run failed"); } finally { rmSync(cwd, { recursive: true, force: true }); }