From aa25a3344815ba609cdc2f3175469b54c3a14e2f Mon Sep 17 00:00:00 2001 From: Hans Larsen Date: Thu, 27 Sep 2018 12:36:06 -0400 Subject: [PATCH] feat(@angular/cli): show project being linted Fixes #11231 --- packages/angular/cli/commands/lint-impl.ts | 8 ++- .../angular/cli/models/architect-command.ts | 50 ++++++++++--------- 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/packages/angular/cli/commands/lint-impl.ts b/packages/angular/cli/commands/lint-impl.ts index bf35c053a966..a67a8563d951 100644 --- a/packages/angular/cli/commands/lint-impl.ts +++ b/packages/angular/cli/commands/lint-impl.ts @@ -5,7 +5,7 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ - +import { TargetSpecifier } from '@angular-devkit/architect'; import { ArchitectCommand, ArchitectCommandOptions } from '../models/architect-command'; import { Arguments } from '../models/interface'; import { Schema as LintCommandSchema } from './lint'; @@ -14,6 +14,12 @@ export class LintCommand extends ArchitectCommand { public readonly target = 'lint'; public readonly multiTarget = true; + protected async runSingleTarget(targetSpec: TargetSpecifier, options: string[]) { + this.logger.info(`Linting ${JSON.stringify(targetSpec.project)}...`); + + return super.runSingleTarget(targetSpec, options); + } + public async run(options: ArchitectCommandOptions & Arguments) { return this.runArchitectTarget(options); } diff --git a/packages/angular/cli/models/architect-command.ts b/packages/angular/cli/models/architect-command.ts index 38b7b59814f4..729afd19966f 100644 --- a/packages/angular/cli/models/architect-command.ts +++ b/packages/angular/cli/models/architect-command.ts @@ -135,31 +135,33 @@ export abstract class ArchitectCommand< return await this.runArchitectTarget(options); } + protected async runSingleTarget(targetSpec: TargetSpecifier, options: string[]) { + // We need to build the builderSpec twice because architect does not understand + // overrides separately (getting the configuration builds the whole project, including + // overrides). + const builderConf = this._architect.getBuilderConfiguration(targetSpec); + const builderDesc = await this._architect.getBuilderDescription(builderConf).toPromise(); + const targetOptionArray = await parseJsonSchemaToOptions(this._registry, builderDesc.schema); + const overrides = parseArguments(options, targetOptionArray); + + if (overrides['--']) { + (overrides['--'] || []).forEach(additional => { + this.logger.warn(`Unknown option: '${additional.split(/=/)[0]}'`); + }); + + return 1; + } + const realBuilderConf = this._architect.getBuilderConfiguration({ ...targetSpec, overrides }); + + return this._architect.run(realBuilderConf, { logger: this._logger }).pipe( + map((buildEvent: BuildEvent) => buildEvent.success ? 0 : 1), + ).toPromise(); + } + protected async runArchitectTarget( options: ArchitectCommandOptions & Arguments, ): Promise { - const runSingleTarget = async (targetSpec: TargetSpecifier) => { - // We need to build the builderSpec twice because architect does not understand - // overrides separately (getting the configuration builds the whole project, including - // overrides). - const builderConf = this._architect.getBuilderConfiguration(targetSpec); - const builderDesc = await this._architect.getBuilderDescription(builderConf).toPromise(); - const targetOptionArray = await parseJsonSchemaToOptions(this._registry, builderDesc.schema); - const overrides = parseArguments(options['--'] || [], targetOptionArray); - - if (overrides['--']) { - (overrides['--'] || []).forEach(additional => { - this.logger.warn(`Unknown option: '${additional.split(/=/)[0]}'`); - }); - - return 1; - } - const realBuilderConf = this._architect.getBuilderConfiguration({ ...targetSpec, overrides }); - - return this._architect.run(realBuilderConf, { logger: this._logger }).pipe( - map((buildEvent: BuildEvent) => buildEvent.success ? 0 : 1), - ).toPromise(); - }; + const extra = options['--'] || []; try { const targetSpec = this._makeTargetSpecifier(options); @@ -167,13 +169,13 @@ export abstract class ArchitectCommand< // This runs each target sequentially. // Running them in parallel would jumble the log messages. return await from(this.getProjectNamesByTarget(this.target)).pipe( - concatMap(project => from(runSingleTarget({ ...targetSpec, project }))), + concatMap(project => from(this.runSingleTarget({ ...targetSpec, project }, extra))), toArray(), map(results => results.every(res => res === 0) ? 0 : 1), ) .toPromise(); } else { - return await runSingleTarget(targetSpec); + return await this.runSingleTarget(targetSpec, extra); } } catch (e) { if (e instanceof schema.SchemaValidationException) {