-
-
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
Handled exception of--file
option with non-existed file(#4047)
#4056
Conversation
- Function `handleRequires` is used both when commanded using --require and --file.
ref: #4047 |
…`--file` - rollback annotation of Function `handleRequires`
exports.handleFiles = (files = []) => { | ||
files.forEach(file => { | ||
if (!fs.existsSync(file, {cwd})) { | ||
throw Error(`Cannot find module '${file}'`); |
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.
Could you add a test for this please.
@@ -79,6 +79,7 @@ exports.list = str => | |||
* @param {string[]} requires - Modules to require | |||
* @private | |||
*/ | |||
|
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.
Doesnt need the space (same below)
🤖 Closing out old PRs to keep the queue small. Please yell at me if you'd like to keep working on this. Cheers! |
Description of the Change
In handleRequires, a function that handles exceptions when invoking a module that does not exist with the
--require
option. However, function handleRequires can also be used to load non-existent files with the--file
option.So I added this function to be called when I loaded the file using --file option. And I modified the annotation of this function.
Benefits
When user import a non-existent file or module, command line can show the user the same error message and format.