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

Warn when man or bin directory not found but don't crash #1663

Merged
merged 4 commits into from Nov 17, 2016

Conversation

ghost
Copy link

@ghost ghost commented Nov 3, 2016

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.

for (const scriptName of await fs.readdir(path.join(moduleLoc, binDir))) {
if (scriptName[0] === '.') {
continue;
try {
Copy link
Contributor

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.

Copy link
Author

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here too please.

@ghost
Copy link
Author

ghost commented Nov 8, 2016

@kittens: Changes per the review are done. Thanks for the input.

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

Successfully merging this pull request may close these issues.

None yet

1 participant