-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add informative message for missing executable on Windows #2291
Add informative message for missing executable on Windows #2291
Conversation
28966a8
to
8762e44
Compare
Ouch. The new failure mode was hard to get working with the existing tests, but refactoring into a separate routine allowed suppressing the behaviour so existing tests could stay much the same. |
lib/command.js
Outdated
* @param {string} executableDir | ||
* @param {string} subcommandName | ||
*/ | ||
_throwForMissingExecutable(executableFile, executableDir, subcommandName) { |
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.
The method name is _throwForMissingExecutable
, but it may not throw, so why not name it something like _validateExecutable
?
Or how about doing the checks outside of the method?
if (!fs.existsSync(executableFile)) {
_throwForMissingExecutable(...);
}
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.
method name
Oh, yes. I originally had the check outside the routine. Will change name.
Or how about doing the checks outside of the method?
I agree that would be tidier for the code and usage. However, I started that way, and multiple unit tests check whether fs.existsSync
has been called and broke. I didn't think of an easy way of fixing the tests, other than moving the fs. fs.existsSync
inside the routine. Then easy to completely bypass the new code and run the old tests.
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.
We have several _checkForX
routines already so following that style, _checkForMissingExecutable
.
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.
Lots!
_checkForMissingMandatoryOptions
_checkForConflictingLocalOptions
_checkForConflictingOptions
_checkForBrokenPassThrough
Problem
There is an informative runtime message to help the author when fail to find a stand-alone subcommand, but the message does not appear on Windows.
See: #2290
Solution
Windows always tries opening the executable as an argument to node. Test for the existence of the file first.
ChangeLog