Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call to _exit still exits the process, despite registering a callback #2092

Closed
febeling opened this issue Nov 30, 2023 · 4 comments
Closed

Comments

@febeling
Copy link

Call to _exit still exits the process (e.g. from process.error), despite registering a callback via exitOverride.

https://github.com/tj/commander.js/blame/f1ae2db8e2da01d6efcbfd59cbf82202f864b0c1/lib/command.js#L459-L465

What was the purpose of #1040?

Is the idea that I register a callback, but I have to throw an error from it?

Why isn't the exit skipped over if there's an override?

@shadowspawn
Copy link
Collaborator

shadowspawn commented Nov 30, 2023

Commander is not set up to gracefully recover from an error that would normally call process.exit(), it expects processing to stop. So the exitOverride callback still has to terminate the normal program flow, usually by throwing an error but could also be by calling process.exit() with a custom error code.

@febeling
Copy link
Author

Ok. Thanks for the quick response. Fwiw, I didn't understand that from reading the docs of exitOverride.

@shadowspawn
Copy link
Collaborator

I had a go at making this clearer: #2098

@febeling
Copy link
Author

febeling commented Dec 9, 2023

That sets expectations clearly. Thanks for addressing the issue!

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

No branches or pull requests

2 participants