Skip to content

Commit

Permalink
fix: check result when determining exit code of ls <filter>
Browse files Browse the repository at this point in the history
PR-URL: #1986
Credit: @G-Rath
Close: #1986
Reviewed-by: @ruyadorno
  • Loading branch information
G-Rath authored and ruyadorno committed Oct 20, 2020
1 parent 89fbf73 commit ce4724a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
5 changes: 5 additions & 0 deletions test/lib/ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
})
Expand Down

0 comments on commit ce4724a

Please sign in to comment.