'npm outdated --json' not always JSON.

What I Wanted to Do

machine parse about one thousand outdated reports. In the event that there are no outdated packages,
NPM should understand the --json bit meansā€¦i am expecting jsonā€¦ and should return at least a '{}' or something.

What Happened Instead

If you run npm outdated --json [--long] in a package with no outdated dependencies,
it does not write to stdout.

If someone is using --json, they are expecting json in the stdout. a zero-length string is not a valid JSON string.

Reproduction Steps

go to literally any directory with a package.json that is fully up-to-date. run npm outdated --json.

'' is not a valid json string. Mind you, '""' is, as is '{}'. But an empty string cannot be parsed as json,
though some implementations (like jq) are smart enough to figure it out.

Details

Platform Info

npm version 6.7.0

This does indeed seem like a very good first contrib! Iā€™ve tagged it as such. Thank you!

Created https://github.com/npm/cli/pull/176

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.