File tree 1 file changed +9
-4
lines changed
packages/@angular/cli/utilities
1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 1
1
const SilentError = require ( 'silent-error' ) ;
2
2
const chalk = require ( 'chalk' ) ;
3
3
4
+ import { oneLine } from 'common-tags' ;
4
5
import { CliConfig } from '../models/config' ;
5
6
6
7
export function getAppFromConfig ( nameOrIndex ?: String ) {
@@ -9,17 +10,21 @@ export function getAppFromConfig(nameOrIndex?: String) {
9
10
throw new SilentError ( chalk . red ( 'Unable to find any apps in `.angular-cli.json`.' ) ) ;
10
11
}
11
12
12
- let app = apps [ 0 ] ;
13
13
if ( nameOrIndex ) {
14
14
if ( nameOrIndex . match ( / ^ [ 0 - 9 ] + $ / ) ) {
15
15
const index = parseInt ( nameOrIndex . toString ( ) , 10 ) ;
16
- app = apps [ index ] ;
16
+ if ( apps [ index ] ) {
17
+ return apps [ index ] ;
18
+ }
17
19
} else {
18
20
const filtered = apps . filter ( ( currentApp : any ) => currentApp . name === nameOrIndex ) ;
19
21
if ( filtered . length > 0 ) {
20
- app = filtered [ 0 ] ;
22
+ return filtered [ 0 ] ;
21
23
}
22
24
}
25
+ } else {
26
+ return apps [ 0 ] ;
23
27
}
24
- return app ;
28
+ throw new SilentError ( chalk . red ( oneLine `Unable to find app with name or index.
29
+ Make you have proper apps configuration in \`.angular-cli.json\`` ) ) ;
25
30
}
You can’t perform that action at this time.
0 commit comments