Skip to content

Commit ab14e03

Browse files
committed
Report an error if associatedCommands refers to a command that does not exist
1 parent 386879e commit ab14e03

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

apps/rush-lib/src/cli/actions/CustomCommandFactory.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,15 @@ export class CustomCommandFactory {
8585
+ ` using an unsupported command kind "${command!.commandKind}"`);
8686
}
8787
}
88+
89+
// Check for any invalid associations
90+
for (const parameter of commandLineConfiguration.parameters) {
91+
for (const associatedCommand of parameter.associatedCommands) {
92+
if (!parser.tryGetAction(associatedCommand)) {
93+
throw new Error(`${RushConstants.commandLineFilename} defines a parameter "${parameter.longName}"`
94+
+ ` that is associated with a nonexistent command "${associatedCommand}"`);
95+
}
96+
}
97+
}
8898
}
8999
}

apps/rush-lib/src/cli/actions/test/repo/common/config/rush/command-line.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"shortName": "-m",
5656
"parameterKind": "flag",
5757
"description": "Perform a fast build, which disables certain tasks such as unit tests and linting",
58-
"associatedCommands": [ "build", "rebuild", "deploy" ]
58+
"associatedCommands": [ "build", "rebuild" ]
5959
}
6060
]
6161
}

0 commit comments

Comments
 (0)