Skip to content

Commit

Permalink
feat(@angular/cli): show project being linted
Browse files Browse the repository at this point in the history
Fixes #11231
  • Loading branch information
hansl committed Sep 27, 2018
1 parent 5d8af57 commit aa25a33
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 25 deletions.
8 changes: 7 additions & 1 deletion packages/angular/cli/commands/lint-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -14,6 +14,12 @@ export class LintCommand extends ArchitectCommand<LintCommandSchema> {
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);
}
Expand Down
50 changes: 26 additions & 24 deletions packages/angular/cli/models/architect-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,45 +135,47 @@ 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<number> {
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);
if (!targetSpec.project && this.target) {
// 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) {
Expand Down

0 comments on commit aa25a33

Please sign in to comment.