Skip to content

Commit ca20943

Browse files
committed
fix(update): exit non-zero when CLI upgrade fails
1 parent 3be62c7 commit ca20943

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

‎packages/commands/src/commands/update.ts‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
DEFAULT_INSTALL_PS1_URL,
77
DEFAULT_INSTALL_SCRIPT_URL,
88
defineCommand,
9+
ExitCode,
910
getConfigDir,
1011
getUpdateInstallMethod,
1112
type InstallMethod,
@@ -155,9 +156,12 @@ export default defineCommand({
155156
error instanceof BailianError && error.hint
156157
? error.hint.replace(/^Re-run:\s*/i, "")
157158
: binaryReinstallHint().trim();
158-
process.stderr.write(`\nAutomatic binary update failed: ${message}\n`);
159-
process.stderr.write("Re-run the install script:\n");
160-
process.stderr.write(` ${reinstall}\n\n`);
159+
throw new BailianError(
160+
`Automatic binary update failed: ${message}`,
161+
ExitCode.GENERAL,
162+
`Re-run the install script:\n ${reinstall}`,
163+
{ cause: error },
164+
);
161165
}
162166
return;
163167
}
@@ -179,9 +183,13 @@ export default defineCommand({
179183
process.stderr.write(`\n${color.green("\u2713 Update complete.")}\n`);
180184
}
181185
updateAgentSkill(color);
182-
} catch {
183-
process.stderr.write("\nAutomatic update failed. Please run manually:\n");
184-
process.stderr.write(` ${cmd}\n\n`);
186+
} catch (error) {
187+
throw new BailianError(
188+
"Automatic update failed.",
189+
ExitCode.GENERAL,
190+
`Please run manually:\n ${cmd}`,
191+
{ cause: error },
192+
);
185193
}
186194
},
187195
});

0 commit comments

Comments
 (0)