fix(cli): replace process.exit(0) with proper exit handling

- Use process.exitCode + return in select cancel path
- Use process.exitCode + throw in group onCancel handler
- Allows finally blocks to run for cleanup
This commit is contained in:
ZTatman 2026-04-12 18:22:06 -04:00
parent a7f30a0d3a
commit 55d45adec8

View file

@ -105,7 +105,8 @@ async function init(opts: { output?: string }) {
if (p.isCancel(choice) || choice === "cancel") {
p.cancel("\nOperation cancelled.");
process.exit(0);
process.exitCode = 0;
return;
}
if (choice === "view") {
@ -173,7 +174,8 @@ async function init(opts: { output?: string }) {
{
onCancel: () => {
p.cancel("\nOperation cancelled.");
process.exit(0);
process.exitCode = 0;
throw new Error("Operation cancelled");
},
},
);