Skip to content

Commit

Permalink
fix(list): Restore empty --json array output when no results
Browse files Browse the repository at this point in the history
Fixes #1945
  • Loading branch information
evocateur committed Feb 26, 2019
1 parent 93ac976 commit 2c925bd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions commands/list/__tests__/list-command.test.js
Expand Up @@ -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", () => {
Expand Down
2 changes: 1 addition & 1 deletion commands/list/index.js
Expand Up @@ -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);
}

Expand Down

0 comments on commit 2c925bd

Please sign in to comment.