-
Notifications
You must be signed in to change notification settings - Fork 2.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
Warn when man or bin directory not found but don't crash #1663
Conversation
for (const scriptName of await fs.readdir(path.join(moduleLoc, binDir))) { | ||
if (scriptName[0] === '.') { | ||
continue; | ||
try { |
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 we do await fs.exists()
here instead of the try-catch
? Seems much nicer.
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.
fs.exists is deprecated. I'm not sure how long it has been deprecated and the other options of fs.stat() or fs.access() seem like they would have the same problem of having the error thrown.
for (const filename of await fs.readdir(path.join(moduleLoc, manDir))) { | ||
if (/^(.*?)\.[0-9]$/.test(filename)) { | ||
man.push(path.join('.', manDir, filename)); | ||
try { |
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.
Here too please.
@kittens: Changes per the review are done. Thanks for the input. |
Summary
Fixes situation where the bin or man directory is specified in the package.json but does not really exist. This change is to address issues like #739
Test plan
yarn add newman@3.2.0 succeeds to install. Previously when installing dependency postman-collection@0.5.5 yarn would crash with an ENOENT trying to read the bin directory that doesn't exist.