diff options
author | Gareth Jones <jones258@gmail.com> | 2020-10-18 22:07:29 +0300 |
---|---|---|
committer | Ruy Adorno <ruyadorno@hotmail.com> | 2020-10-20 21:21:23 +0300 |
commit | ce4724a3835ded9a4a29d8d67323f925461155e5 (patch) | |
tree | c40268ff113b62ef1e30851f5c25f7debb8d0010 | |
parent | 89fbf733f95b3c7633877a97eb02be243ee92c6f (diff) |
fix: check `result` when determining exit code of `ls <filter>`
PR-URL: https://github.com/npm/cli/pull/1986
Credit: @G-Rath
Close: #1986
Reviewed-by: @ruyadorno
-rw-r--r-- | lib/ls.js | 2 | ||||
-rw-r--r-- | test/lib/ls.js | 5 |
2 files changed, 6 insertions, 1 deletions
@@ -488,7 +488,7 @@ const ls = async (args) => { ) // if filtering items, should exit with error code on no results - if (!tree[_include] && args.length) { + if (result && !result[_include] && args.length) { process.exitCode = 1 } diff --git a/test/lib/ls.js b/test/lib/ls.js index db4ba81ee..6a91e8c35 100644 --- a/test/lib/ls.js +++ b/test/lib/ls.js @@ -2476,6 +2476,11 @@ t.test('ls --json', (t) => { }, 'should output json contaning only occurences of filtered by package' ) + t.equal( + process.exitCode, + 0, + 'should exit with error code 0' + ) t.end() }) }) |