fix: exit non-zero when the CLI crashes#516
Closed
lemuelroberto wants to merge 1 commit into
Closed
Conversation
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 detectedLatest commit: 6f3b428 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Member
|
Hey @lemuelroberto, i'll close this PR since its already implemented on our |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@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-pluginversion 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.tsusedmain().catch(console.error)but left the process exit code at the default0.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!