Skip to content

Commit 00f913c

Browse files
committed
fix(@angular/cli): fix angular-cli logic
The old logic was failing if the global angular-cli config was .angular-cli.json.
1 parent 7549d2b commit 00f913c

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

packages/@angular/cli/models/config.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,12 @@ const configCacheMap = new Map<string, CliConfigBase<ConfigInterface>>();
2222

2323
export class CliConfig extends CliConfigBase<ConfigInterface> {
2424
static configFilePath(projectPath?: string): string {
25+
const configNames = [CLI_CONFIG_FILE_NAME, CLI_CONFIG_FILE_NAME_ALT];
2526
// Find the configuration, either where specified, in the Angular CLI project
2627
// (if it's in node_modules) or from the current process.
27-
return (projectPath && findUp(CLI_CONFIG_FILE_NAME, projectPath))
28-
|| (projectPath && findUp(CLI_CONFIG_FILE_NAME_ALT, projectPath))
29-
|| findUp(CLI_CONFIG_FILE_NAME, process.cwd())
30-
|| findUp(CLI_CONFIG_FILE_NAME_ALT, process.cwd())
31-
|| findUp(CLI_CONFIG_FILE_NAME, __dirname)
32-
|| findUp(CLI_CONFIG_FILE_NAME_ALT, __dirname);
28+
return (projectPath && findUp(configNames, projectPath))
29+
|| findUp(configNames, process.cwd())
30+
|| findUp(configNames, __dirname);
3331
}
3432

3533
static globalConfigFilePath(): string {

packages/@angular/cli/utilities/find-up.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
import * as path from 'path';
22
import { existsSync } from 'fs';
33

4-
export function findUp(name: string, from: string, stopOnNodeModules = false) {
4+
export function findUp(names: string | string[], from: string, stopOnNodeModules = false) {
5+
if (!Array.isArray(names)) {
6+
names = [names];
7+
}
58
const root = path.parse(from).root;
69

710
let currentDir = from;
811
while (currentDir && currentDir !== root) {
9-
const p = path.join(currentDir, name);
10-
if (existsSync(p)) {
11-
return p;
12+
for (const name of names) {
13+
const p = path.join(currentDir, name);
14+
if (existsSync(p)) {
15+
return p;
16+
}
1217
}
1318

1419
if (stopOnNodeModules) {

0 commit comments

Comments
 (0)