diff options
author | Sreeram Jayan <sreeram.jayan@cerner.com> | 2019-03-20 18:06:06 +0300 |
---|---|---|
committer | isaacs <i@izs.me> | 2019-06-30 06:23:54 +0300 |
commit | 87fef4e356f30941f2ee39f2f774ad2086239a00 (patch) | |
tree | 428685f4541af309408fed12f855c56ce1d48c03 /lib/outdated.js | |
parent | d9238af0b4a3d368b79e54d1636e4aab80bb537f (diff) |
fix: Always return JSON for outdated --json
Close: https://github.com/npm/cli/pull/176
EDIT: Added test, do not set exitStatus to 1 if we're just printing an
empty list as JSON. -- @isaacs
Diffstat (limited to 'lib/outdated.js')
-rw-r--r-- | lib/outdated.js | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/outdated.js b/lib/outdated.js index 17b941461..bb4c346f9 100644 --- a/lib/outdated.js +++ b/lib/outdated.js @@ -101,7 +101,10 @@ function outdated (args, silent, cb) { return aa[0].path.localeCompare(bb[0].path) || aa[1].localeCompare(bb[1]) }) - if (er || silent || list.length === 0) return cb(er, list) + if (er || silent || + (list.length === 0 && !opts.json)) { + return cb(er, list) + } if (opts.json) { output(makeJSON(list, opts)) } else if (opts.parseable) { @@ -129,7 +132,7 @@ function outdated (args, silent, cb) { } output(table(outTable, tableOpts)) } - process.exitCode = 1 + process.exitCode = list.length ? 1 : 0 cb(null, list.map(function (item) { return [item[0].parent.path].concat(item.slice(1, 7)) })) }) })) |