Skip to content

Commit 4a6ea44

Browse files
committed
fix(@angular/cli): show an error if invalid global config file found
Fixes angular#12198
1 parent a5bb3ce commit 4a6ea44

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

packages/angular/cli/lib/cli/index.ts

+9
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import { logging, terminal } from '@angular-devkit/core';
1010
import { filter } from 'rxjs/operators';
1111
import { runCommand } from '../../models/command-runner';
12+
import { getWorkspaceRaw } from '../../utilities/config';
1213
import { getWorkspaceDetails } from '../../utilities/project';
1314

1415

@@ -21,6 +22,14 @@ export default async function(options: { testing?: boolean, cliArgs: string[] })
2122

2223
let projectDetails = getWorkspaceDetails();
2324
if (projectDetails === null) {
25+
const [, localPath] = getWorkspaceRaw('local');
26+
if (localPath !== null) {
27+
logger.fatal(`An invalid configuration file was found ['${localPath}'].`
28+
+ ' Please delete the file before running the command.');
29+
30+
return 1;
31+
}
32+
2433
projectDetails = { root: process.cwd() };
2534
}
2635

packages/angular/cli/models/command.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ export abstract class Command<T extends BaseCommandOptions = BaseCommandOptions>
112112
async validateScope(): Promise<void> {
113113
switch (this.description.scope) {
114114
case CommandScope.OutProject:
115-
if (this.workspace.configFile || getWorkspace('local') !== null) {
115+
if (this.workspace.configFile) {
116116
this.logger.fatal(tags.oneLine`
117117
The ${this.description.name} command requires to be run outside of a project, but a
118-
project definition was found at "${this.workspace.root}".
118+
project definition was found at "${this.workspace.configFile}".
119119
`);
120120
throw 1;
121121
}

0 commit comments

Comments
 (0)