Skip to content

Commit c8a5526

Browse files
committed
fix(run): Exit early when no packages contain the targeted lifecycle
1 parent bea6bc3 commit c8a5526

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

commands/run/__tests__/run-command.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ describe("RunCommand", () => {
126126

127127
await lernaRun(testDir)("missing-script");
128128

129-
expect(consoleOutput()).toBe("");
129+
expect(loggingOutput("success")).toContain(
130+
"No packages found with the lifecycle script 'missing-script'"
131+
);
130132
});
131133

132134
it("runs a script in all packages with --parallel", async () => {

commands/run/index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ class RunCommand extends Command {
4747
}
4848

4949
if (!this.packagesWithScript.length) {
50-
this.logger.warn(`No packages found with the npm script '${script}'`);
50+
this.logger.success("run", `No packages found with the lifecycle script '${script}'`);
51+
52+
// still exits zero, aka "ok"
53+
return false;
5154
}
5255

5356
if (parallel || stream) {
@@ -70,10 +73,8 @@ class RunCommand extends Command {
7073
}
7174

7275
return chain.then(() => {
73-
if (this.packagesWithScript.length) {
74-
this.logger.success("run", `Ran npm script '${this.script}' in packages:`);
75-
this.logger.success("", this.packagesWithScript.map(pkg => `- ${pkg.name}`).join("\n"));
76-
}
76+
this.logger.success("run", `Ran npm script '${this.script}' in packages:`);
77+
this.logger.success("", this.packagesWithScript.map(pkg => `- ${pkg.name}`).join("\n"));
7778
});
7879
}
7980

0 commit comments

Comments
 (0)