fix(@angular/cli): show an error if invalid global config file found

Fixes #12198
This commit is contained in:
Charles Lyding 2018-09-12 11:55:53 -04:00 committed by Keen Yee Liau
parent 6133eb23d3
commit 57a32c2ef5
2 changed files with 11 additions and 2 deletions

View File

@ -9,6 +9,7 @@
import { logging, terminal } from '@angular-devkit/core';
import { filter } from 'rxjs/operators';
import { runCommand } from '../../models/command-runner';
import { getWorkspaceRaw } from '../../utilities/config';
import { getWorkspaceDetails } from '../../utilities/project';
@ -21,6 +22,14 @@ export default async function(options: { testing?: boolean, cliArgs: string[] })
let projectDetails = getWorkspaceDetails();
if (projectDetails === null) {
const [, localPath] = getWorkspaceRaw('local');
if (localPath !== null) {
logger.fatal(`An invalid configuration file was found ['${localPath}'].`
+ ' Please delete the file before running the command.');
return 1;
}
projectDetails = { root: process.cwd() };
}

View File

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