mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-16 02:24:10 +08:00
fix(@angular/cli): show an error if invalid global config file found
Fixes #12198
This commit is contained in:
parent
6133eb23d3
commit
57a32c2ef5
@ -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() };
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user