Skip to content

[BUG] "npm outdated --json" should not have exit code 1 #1109

@danawoodman

Description

@danawoodman

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 like exec/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 to npm 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions