Skip to content

Commit ce4724a

Browse files
G-Rathruyadorno
authored andcommitted
fix: check result when determining exit code of ls <filter>
PR-URL: #1986 Credit: @G-Rath Close: #1986 Reviewed-by: @ruyadorno
1 parent 89fbf73 commit ce4724a

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

lib/ls.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ const ls = async (args) => {
488488
)
489489

490490
// if filtering items, should exit with error code on no results
491-
if (!tree[_include] && args.length) {
491+
if (result && !result[_include] && args.length) {
492492
process.exitCode = 1
493493
}
494494

test/lib/ls.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2476,6 +2476,11 @@ t.test('ls --json', (t) => {
24762476
},
24772477
'should output json contaning only occurences of filtered by package'
24782478
)
2479+
t.equal(
2480+
process.exitCode,
2481+
0,
2482+
'should exit with error code 0'
2483+
)
24792484
t.end()
24802485
})
24812486
})

0 commit comments

Comments
 (0)