-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
fix: Add error handling for nonexistent file case with --file option #5086
Conversation
- added error handling when using the --file flag to do it the way --require does - added a test to assert that we throw the same type of error
|
- require.resolve() by Node.js follows a Node.js module resolution algo which includes checking if the resolved path actually exists on the file system.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! 😎
Requesting changes on adding a bit more testing. But also let's talk about the direction a bit - I feel nervous adding in process.exit
/throw
s deep within code. Thanks for sending!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JoshuaKGoldberg tagging for re-review just in case this disappeared into the backlog abyss 😅
🔎 Overview
Fixes #4047
--file
option by resolving the argument to an absolute path and check for its existence. We now log a warning and exit if the file does not exist.--require
bubble up to the middleware inlib/cli/run.js
. See here. This specific error occurs inlib/cli/run-helpers.js
in thesingleRun
method when we load files asynchronously. Since we were lacking error handling there, the errors appeared the way they previously did before these changes.