Skip to content

Commit 7fdeac6

Browse files
committed
refactor(@angular/cli): handle undefined ng add collection name
Fixes an issue where JSON help extraction fails if the `ng add` collection name is undefined.
1 parent 57a08c9 commit 7fdeac6

File tree

1 file changed

+9
-2
lines changed
  • packages/angular/cli/src/commands/add

1 file changed

+9
-2
lines changed

packages/angular/cli/src/commands/add/cli.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,11 @@ export default class AddCommandModule
100100
// `ng add @angular/localize -- --package-options`.
101101
.strict(false);
102102

103-
const collectionName = await this.getCollectionName();
103+
const collectionName = this.getCollectionName();
104+
if (!collectionName) {
105+
return localYargs;
106+
}
107+
104108
const workflow = this.getOrCreateWorkflowForBuilder(collectionName);
105109

106110
try {
@@ -401,8 +405,11 @@ export default class AddCommandModule
401405
return false;
402406
}
403407

404-
private async getCollectionName(): Promise<string> {
408+
private getCollectionName(): string | undefined {
405409
let [, collectionName] = this.context.args.positional;
410+
if (!collectionName) {
411+
return undefined;
412+
}
406413

407414
// The CLI argument may specify also a version, like `ng add @my/[email protected]`,
408415
// but here we need only the name of the package, like `@my/lib`

0 commit comments

Comments
 (0)