diff --git a/commands/list/__tests__/list-command.test.js b/commands/list/__tests__/list-command.test.js index 248132b8e7..ef780b49d2 100644 --- a/commands/list/__tests__/list-command.test.js +++ b/commands/list/__tests__/list-command.test.js @@ -233,6 +233,15 @@ package-2 }, ]); }); + + it("emits empty array with no results", async () => { + const testDir = await initFixture("basic"); + + collectUpdates.setUpdated(testDir); + await lernaLs(testDir)("--since", "deadbeef", "--json"); + + expect(JSON.parse(output.logged())).toEqual([]); + }); }); describe("in a Yarn workspace", () => { diff --git a/commands/list/index.js b/commands/list/index.js index cec692dec6..c30840e8d2 100644 --- a/commands/list/index.js +++ b/commands/list/index.js @@ -29,7 +29,7 @@ class ListCommand extends Command { execute() { // piping to `wc -l` should not yield 1 when no packages matched - if (this.result.count) { + if (this.result.text.length) { output(this.result.text); }