Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGareth Jones <jones258@gmail.com>2020-10-18 22:07:29 +0300
committerRuy Adorno <ruyadorno@hotmail.com>2020-10-20 21:21:23 +0300
commitce4724a3835ded9a4a29d8d67323f925461155e5 (patch)
treec40268ff113b62ef1e30851f5c25f7debb8d0010
parent89fbf733f95b3c7633877a97eb02be243ee92c6f (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.js2
-rw-r--r--test/lib/ls.js5
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/ls.js b/lib/ls.js
index d55cdfb45..2dd6e4d4e 100644
--- a/lib/ls.js
+++ b/lib/ls.js
@@ -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()
})
})