fix(cli): exit with non-zero code when it fails to start#7010
fix(cli): exit with non-zero code when it fails to start#7010chenjiahan merged 2 commits intomainfrom
Conversation
Summary of ChangesHello @Timeless0911, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the robustness of the CLI by implementing a standard practice for error reporting. By ensuring the process terminates with a non-zero exit code upon failure, it provides a clear signal to calling environments, such as CI/CD pipelines or shell scripts, that an operation did not complete successfully. This change improves the overall reliability and diagnosability of CLI-based workflows. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Pull request overview
This PR adds error handling to ensure the CLI exits with a non-zero exit code when it fails to start. Previously, when setupCommands() threw an error (e.g., due to an unknown option), the process would log the error but exit with code 0, making it difficult to detect failures in scripts or CI/CD pipelines.
Changes:
- Added
process.exit(1)to the error handler inrunCLI()to ensure non-zero exit codes on failures - Added a test case to verify CLI exits with code 1 when unknown options are provided
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/core/src/cli/index.ts | Added process.exit(1) in the error catch block to exit with non-zero code on CLI startup failures |
| e2e/cases/cli/unknown-option/src/index.js | Created minimal entry point file for the unknown-option test case |
| e2e/cases/cli/unknown-option/index.test.ts | Added test to verify CLI exits with error code 1 when unknown options are provided |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Deploying rsbuild-v2 with
|
| Latest commit: |
ba75636
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://ab0c52c3.rsbuild-v2.pages.dev |
| Branch Preview URL: | https://fix-cli-exit-code.rsbuild-v2.pages.dev |
There was a problem hiding this comment.
Code Review
This pull request correctly ensures the CLI exits with a non-zero code on failure by adding process.exit(1) to the main error handling block. The accompanying e2e test is a great addition. I've suggested a small improvement to the test to make it more robust by ensuring it fails if the CLI command doesn't throw an error as expected.
|
@Timeless0911 I've opened a new pull request, #7012, to work on those changes. Once the pull request is ready, I'll request review from you. |
Summary
Ensure the CLI process exits with a non-zero exit code (1) when it fails to start.
Checklist