diff --git a/packages/angular/cli/lib/cli/index.ts b/packages/angular/cli/lib/cli/index.ts index fd55a21a6731..c38285ffdecd 100644 --- a/packages/angular/cli/lib/cli/index.ts +++ b/packages/angular/cli/lib/cli/index.ts @@ -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() }; } diff --git a/packages/angular/cli/models/command.ts b/packages/angular/cli/models/command.ts index 932cd62ad4d5..b7c2cd1d0874 100644 --- a/packages/angular/cli/models/command.ts +++ b/packages/angular/cli/models/command.ts @@ -112,10 +112,10 @@ export abstract class Command async validateScope(): Promise { 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; }