File tree 1 file changed +15
-6
lines changed
packages/angular/cli/src/commands/add
1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -100,7 +100,11 @@ export default class AddCommandModule
100
100
// `ng add @angular/localize -- --package-options`.
101
101
. strict ( false ) ;
102
102
103
- const collectionName = await this . getCollectionName ( ) ;
103
+ const collectionName = this . getCollectionName ( ) ;
104
+ if ( ! collectionName ) {
105
+ return localYargs ;
106
+ }
107
+
104
108
const workflow = this . getOrCreateWorkflowForBuilder ( collectionName ) ;
105
109
106
110
try {
@@ -401,14 +405,19 @@ export default class AddCommandModule
401
405
return false ;
402
406
}
403
407
404
- private async getCollectionName ( ) : Promise < string > {
405
- let [ , collectionName ] = this . context . args . positional ;
408
+ private getCollectionName ( ) : string | undefined {
409
+ const [ , collectionName ] = this . context . args . positional ;
410
+ if ( ! collectionName ) {
411
+ return undefined ;
412
+ }
406
413
407
414
// The CLI argument may specify also a version, like `ng add @my/[email protected] `,
408
- // but here we need only the name of the package, like `@my/lib`
415
+ // but here we need only the name of the package, like `@my/lib`.
409
416
try {
410
- const packageIdentifier = npa ( collectionName ) ;
411
- collectionName = packageIdentifier . name ?? collectionName ;
417
+ const packageName = npa ( collectionName ) . name ;
418
+ if ( packageName ) {
419
+ return packageName ;
420
+ }
412
421
} catch ( e ) {
413
422
assertIsError ( e ) ;
414
423
this . context . logger . error ( e . message ) ;
You can’t perform that action at this time.
0 commit comments