Skip to content

Commit

Permalink
fix(run): only use run-one when not passing multiple scripts (#3620)
Browse files Browse the repository at this point in the history
  • Loading branch information
fahslaj committed Mar 27, 2023
1 parent dbc6df8 commit 9db1572
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
38 changes: 38 additions & 0 deletions e2e/run/task-runner/src/multiple-targets/assertions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,44 @@ describe("lerna-run-nx-multiple-targets", () => {
`);
});

it("should run multiple comma-delimited targets concurrently for a single package", async () => {
const output = await fixture.readOutput("multiple-targets-single-package");
expect(output).toMatchInlineSnapshot(`
lerna notice cli v999.9.9-e2e.0
lerna notice filter including "package-X"
lerna info filter [ 'package-X' ]
> Lerna (powered by Nx) Running targets XXXXXXXXXX, XXXXXXXXXX for project package-X:
- package-X
> package-X:XXXXXXXXXX
> package-X@0.0.0 XXXXXXXXXX
> echo test-package-X
test-package-X
> package-X:XXXXXXXXXX
> package-X@0.0.0 XXXXXXXXXX
> echo test-package-X
test-package-X
> Lerna (powered by Nx) Successfully ran targets XXXXXXXXXX, XXXXXXXXXX for project package-X
`);
});
});
1 change: 1 addition & 0 deletions e2e/run/task-runner/src/multiple-targets/exec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ initializeFixture $DIR

# Run the relevant task runner commands and write stdout and stderr to a named file in each case (for later assertions)
npx lerna run print-name,print-name-again > $OUTPUTS/multiple-targets.txt 2>&1
npx lerna run print-name,print-name-again --scope="package-3" > $OUTPUTS/multiple-targets-single-package.txt 2>&1

# Run the assertions
runAssertions $DIR $E2E_ROOT $FIXTURE_ROOT_PATH $UPDATE_SNAPSHOTS
2 changes: 1 addition & 1 deletion libs/commands/run/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class RunCommand extends Command {
this.configureNxOutput();
const { targetDependencies, options, extraOptions } = await this.prepNxOptions();

if (this.packagesWithScript.length === 1) {
if (this.packagesWithScript.length === 1 && !Array.isArray(this.script)) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { runOne } = require("nx/src/command-line/run-one");
const fullQualifiedTarget =
Expand Down

0 comments on commit 9db1572

Please sign in to comment.