mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 21:24:31 +00:00
fix(cli): exit with non-zero code when configure/agents-add wizards are cancelled (#14156)
* fix(cli): exit with non-zero code when configure/agents-add wizards are cancelled Follow-up to the onboard cancel fix. The configure wizard and agents add wizard also caught WizardCancelledError and exited with code 0, which signals success to callers. Change to exit(1) for consistency — user cancellation is not a successful completion. This ensures scripts that chain these commands with set -e will correctly stop when the user cancels. * fix(cli): make wizard cancellations exit non-zero (#14156) (thanks @0xRaini) --------- Co-authored-by: Rain <rain@Rains-MBA-M4.local> Co-authored-by: Sebastian <19554889+sebslight@users.noreply.github.com>
This commit is contained in:
@@ -95,6 +95,7 @@ vi.mock("./onboard-channels.js", () => ({
|
||||
setupChannels: vi.fn(),
|
||||
}));
|
||||
|
||||
import { WizardCancelledError } from "../wizard/prompts.js";
|
||||
import { runConfigureWizard } from "./configure.wizard.js";
|
||||
|
||||
describe("runConfigureWizard", () => {
|
||||
@@ -133,4 +134,28 @@ describe("runConfigureWizard", () => {
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("exits with code 1 when configure wizard is cancelled", async () => {
|
||||
const runtime = {
|
||||
log: vi.fn(),
|
||||
error: vi.fn(),
|
||||
exit: vi.fn(),
|
||||
};
|
||||
|
||||
mocks.readConfigFileSnapshot.mockResolvedValue({
|
||||
exists: false,
|
||||
valid: true,
|
||||
config: {},
|
||||
issues: [],
|
||||
});
|
||||
mocks.probeGatewayReachable.mockResolvedValue({ ok: false });
|
||||
mocks.resolveControlUiLinks.mockReturnValue({ wsUrl: "ws://127.0.0.1:18789" });
|
||||
mocks.summarizeExistingConfig.mockReturnValue("");
|
||||
mocks.createClackPrompter.mockReturnValue({});
|
||||
mocks.clackSelect.mockRejectedValueOnce(new WizardCancelledError());
|
||||
|
||||
await runConfigureWizard({ command: "configure" }, runtime);
|
||||
|
||||
expect(runtime.exit).toHaveBeenCalledWith(1);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user