Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/21523-init-refusal-printed-once.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'@objectstack/cli': patch
---

fix(cli): `os init` prints its dependency-install and scaffold-validation refusals once (#21523)

Clause-②: no

`os init demo -p npm` with an unreachable package registry printed `✗ Project scaffolded, but dependency installation failed.`, then a second `✗ Dependency installation failed`, then oclif's `Error: Dependency installation failed`, and exited 2. The second `✗` line came from the command's outer `catch`: the `this.error(…)` inside its `try` throws oclif's exit signal, and the `catch` reported it again. A scaffold that failed its own validation got a second `✗ Scaffold validation failed` line under its refusal the same way.

The `catch` now lets the signal through. Each refusal prints its `✗` line once, followed by oclif's `Error:` line as before, and the exit status is still 2.
5 changes: 5 additions & 0 deletions packages/cli/src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
printAuthoringAdvisories,
printAuthoringRuleErrors,
AUTHORING_ADVISORY_PRINT_LIMIT,
isExitSignal,
} from '../utils/format.js';
import { validateScaffold } from '../utils/scaffold-validate.js';
import { summarizeTree, describeEntry } from 'create-objectstack/created-summary';
Expand Down Expand Up @@ -1389,6 +1390,10 @@ export default class Init extends Command {
}

} catch (error: any) {
// The two refusals above (scaffold self-test, dependency install) already
// printed their `✗` line and raised the exit signal with `this.error`.
// Re-reporting it here printed the refusal a second time.
if (isExitSignal(error)) throw error;
printError(error.message || String(error));
this.error(error.message || String(error));
}
Expand Down
Loading
Loading