Skip to content

fix: exit non-zero when the CLI crashes#516

Closed
lemuelroberto wants to merge 1 commit into
kitajs:masterfrom
lemuelroberto:fix/master/ts-html-plugin-cli-exit-code
Closed

fix: exit non-zero when the CLI crashes#516
lemuelroberto wants to merge 1 commit into
kitajs:masterfrom
lemuelroberto:fix/master/ts-html-plugin-cli-exit-code

Conversation

@lemuelroberto

Copy link
Copy Markdown

@arthurfiorette , first of all, thank you very much for the hard work and the great software you offer to the community.

When running @kitajs/ts-html-plugin version 4.1.4 in the CI, I noticed that it was passing (all green), even though the script was crashing due to TypeScript compatibility issues.

This PR adds a test to reproduce the issue and includes the fix as well.

The top-level handler in cli.ts used main().catch(console.error) but left the process exit code at the default 0.

I verified that this error does not occur in the next branch, so only this PR will be necessary.

Once again, I'm very grateful for your work!

The top-level handler in the ts-html-plugin `cli.ts` used
`main().catch(console.error)`, which logged an uncaught error
but left the process exit code at the default `0`.
Because the CLI is used as an XSS lint gate in CI and pre-commit
hooks, a startup or runtime crash was reported as a passing scan,
letting unscanned code ship while the pipeline stayed green.

Log the error and force `process.exit(1)` so a crash is always
non-zero, while leaving the intentional success (`0`), error (`1`)
and warning (`2`) exit paths untouched. Adds a regression test
that reproduces the crash and asserts a non-zero exit.

Signed-off-by: Lemuel Roberto Bonifácio <code@lemuelroberto.online>
@changeset-bot

changeset-bot Bot commented Jul 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6f3b428

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@kitajs/ts-html-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@arthurfiorette

Copy link
Copy Markdown
Member

Hey @lemuelroberto, i'll close this PR since its already implemented on our next v5 branch. Can you try migrating over to @kitajs/html@next?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants