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

fix(runNpmAudit): Replace error checking from stderr to error #50

Merged
merged 1 commit into from
Feb 7, 2019

Conversation

iranreyes
Copy link
Contributor

Type of change: Bug fixing
Does this introduce a breaking change?: No

Problem description

This pull request tackles down the issue #49

Solution description

If something was returned to the output stream, it should be a formatted json, and it tries to parse it. In case there are issues with the output (couldn't parse the JSON) it will return an error.

If the output is empty will check for errors.

Note: You may want to move the if (_error) to the top, but the current approach is more optimistic and relays on the output and the output JSON.

Side Effects

N/A

Additional comments

Tested on node.js v10.15.1 and npm v6.5.0

Copy link
Member

@quinnturner quinnturner left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! We are considering migrating to using spawn instead of exec (related: #47 #48). We could release this as a temporary fix or just do the migration immediately. @andy-patt thoughts?

}

const parsedAudit = JSON.parse(stdout);
callback(null, parsedAudit);
if (_error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd guess that this variable should be named just error now that it's being used.
This is just nit-picking though; fine to merge as-is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't want to be so invasive with the PR, but I agree with it

@andy-patt
Copy link
Collaborator

@quinnturner It seems like this is an improvement to the status-quo so I'd be in favour of merging it.

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.

3 participants