-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
[BUG] "npm outdated --json" should not have exit code 1 #1109
Comments
Are you sure the json isn’t on stdout, and the error on stderr, which would enable you to easily pipe or separate the json output? |
I logged out |
It seems reasonable to me that, unrelated to exit code, a command with |
@ljharb sweet, I'm glad you agree 😄 I assume this is considered a breaking change tho? |
Seems like a patch to me, but I don't make those decisions here :-) |
Well technically it is a breaking change right? Like if people expected the default output to have exit 1 it would break for them right? Not that I really care, it would just be cool if it was fixed 😄 |
Same thing happens in the case of a Makefile. I understand that at some point that was the desired functionality, but A new package version being available is not an error. Or at least it should respect the |
So now it outputs everything to stdout, but still returns code 1, preventing a sub-process in node from being able to parse the result. |
npm If your bug is preproducible on If your issue was a feature request, please consider opening a new RRFC or RFC. If your issue was a question or other idea that was not CLI-specific, consider opening a discussion on our feedback repo Closing: This is an automated message. |
npm version 8.5.5. |
What / Why
In order to easily parse the output of
npm outdated --json
, this command should always exit cleanly (unless of course an actual error occurs).The reason for this is that because
--json
exits if there are outdated dependencies, using something likeexec
/execFile
to get the stdout fails to work as expected and you instead have to parse error output and remove the first line of the output before parsing the JSON response body.Unless I'm mistake, then JSON output is mean to be parsed, so having a failure output for the perfectly valid scenario of having out of date packages, seems problematic to me.
I suggest that if a users passes
--json
tonpm outdated
, the command always exits cleanly unless an actual error occurs.Example of the output of running
npm outdated --json
in node and getting an error instead of JSON output:When
n/a
Where
CLI
npm: 6.13.7
node: v13.10.1
How
Current Behavior
See description
Steps to Reproduce
Run
npm outdated --json
on a project without out of date dependencies and check error code.Expected Behavior
Don't return an error code if packages are out of date if
--json
flag is provided.Who
All CLI users
References
n/a
The text was updated successfully, but these errors were encountered: