Skip to content

Commit 430cb55

Browse files
sumitarorahansl
authored andcommitted
fix(@angular/cli): fix default app index
1 parent e037877 commit 430cb55

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const SilentError = require('silent-error');
22
const chalk = require('chalk');
33

4+
import { oneLine } from 'common-tags';
45
import { CliConfig } from '../models/config';
56

67
export function getAppFromConfig(nameOrIndex?: String) {
@@ -9,17 +10,21 @@ export function getAppFromConfig(nameOrIndex?: String) {
910
throw new SilentError(chalk.red('Unable to find any apps in `.angular-cli.json`.'));
1011
}
1112

12-
let app = apps[0];
1313
if (nameOrIndex) {
1414
if (nameOrIndex.match(/^[0-9]+$/)) {
1515
const index = parseInt(nameOrIndex.toString(), 10);
16-
app = apps[index];
16+
if (apps[index]) {
17+
return apps[index];
18+
}
1719
} else {
1820
const filtered = apps.filter((currentApp: any) => currentApp.name === nameOrIndex);
1921
if (filtered.length > 0) {
20-
app = filtered[0];
22+
return filtered[0];
2123
}
2224
}
25+
} else {
26+
return apps[0];
2327
}
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\``));
2530
}

0 commit comments

Comments
 (0)