Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(run): add double quotes around script target containing colon #3218

Merged
merged 8 commits into from Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -3,6 +3,7 @@
"version": "1.0.0",
"scripts": {
"fail": "exit 1",
"my-script": "echo package-1"
"my-script": "echo package-1",
"another-script:but-with-colons": "echo package-1-script-with-colons"
}
}
}
7 changes: 7 additions & 0 deletions commands/run/__tests__/run-command.test.js
Expand Up @@ -331,6 +331,13 @@ describe("RunCommand", () => {
expect(collectedOutput).toContain("Successfully ran target");
});

it("runs a script with a colon in the script name", async () => {
collectedOutput = "";
await lernaRun(testDir)("another-script:but-with-colons");
expect(collectedOutput).toContain("package-1-script-with-colons");
expect(collectedOutput).toContain("Successfully ran target");
});

it("runs a script only in scoped packages", async () => {
collectedOutput = "";
await lernaRun(testDir)("my-script", "--scope", "package-1");
Expand Down
2 changes: 1 addition & 1 deletion commands/run/index.js
Expand Up @@ -179,7 +179,7 @@ class RunCommand extends Command {
const { targetDependencies, options } = this.prepNxOptions();
if (this.packagesWithScript.length === 1) {
const { runOne } = require("nx/src/command-line/run-one");
const fullQualifiedTarget = this.packagesWithScript.map((p) => p.name)[0] + ":" + this.script;
const fullQualifiedTarget = this.packagesWithScript.map((p) => p.name)[0] + ":\"" + this.script+ "\"";
return runOne(
process.cwd(),
{
Expand Down