Skip to content

feat(@angular/cli): show project being linted #12384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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