Skip to content

Commit aa25a33

Browse files
committed
feat(@angular/cli): show project being linted
Fixes #11231
1 parent 5d8af57 commit aa25a33

File tree

2 files changed

+33
-25
lines changed

2 files changed

+33
-25
lines changed

packages/angular/cli/commands/lint-impl.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
8+
import { TargetSpecifier } from '@angular-devkit/architect';
99
import { ArchitectCommand, ArchitectCommandOptions } from '../models/architect-command';
1010
import { Arguments } from '../models/interface';
1111
import { Schema as LintCommandSchema } from './lint';
@@ -14,6 +14,12 @@ export class LintCommand extends ArchitectCommand<LintCommandSchema> {
1414
public readonly target = 'lint';
1515
public readonly multiTarget = true;
1616

17+
protected async runSingleTarget(targetSpec: TargetSpecifier, options: string[]) {
18+
this.logger.info(`Linting ${JSON.stringify(targetSpec.project)}...`);
19+
20+
return super.runSingleTarget(targetSpec, options);
21+
}
22+
1723
public async run(options: ArchitectCommandOptions & Arguments) {
1824
return this.runArchitectTarget(options);
1925
}

packages/angular/cli/models/architect-command.ts

+26-24
Original file line numberDiff line numberDiff line change
@@ -135,45 +135,47 @@ export abstract class ArchitectCommand<
135135
return await this.runArchitectTarget(options);
136136
}
137137

138+
protected async runSingleTarget(targetSpec: TargetSpecifier, options: string[]) {
139+
// We need to build the builderSpec twice because architect does not understand
140+
// overrides separately (getting the configuration builds the whole project, including
141+
// overrides).
142+
const builderConf = this._architect.getBuilderConfiguration(targetSpec);
143+
const builderDesc = await this._architect.getBuilderDescription(builderConf).toPromise();
144+
const targetOptionArray = await parseJsonSchemaToOptions(this._registry, builderDesc.schema);
145+
const overrides = parseArguments(options, targetOptionArray);
146+
147+
if (overrides['--']) {
148+
(overrides['--'] || []).forEach(additional => {
149+
this.logger.warn(`Unknown option: '${additional.split(/=/)[0]}'`);
150+
});
151+
152+
return 1;
153+
}
154+
const realBuilderConf = this._architect.getBuilderConfiguration({ ...targetSpec, overrides });
155+
156+
return this._architect.run(realBuilderConf, { logger: this._logger }).pipe(
157+
map((buildEvent: BuildEvent) => buildEvent.success ? 0 : 1),
158+
).toPromise();
159+
}
160+
138161
protected async runArchitectTarget(
139162
options: ArchitectCommandOptions & Arguments,
140163
): Promise<number> {
141-
const runSingleTarget = async (targetSpec: TargetSpecifier) => {
142-
// We need to build the builderSpec twice because architect does not understand
143-
// overrides separately (getting the configuration builds the whole project, including
144-
// overrides).
145-
const builderConf = this._architect.getBuilderConfiguration(targetSpec);
146-
const builderDesc = await this._architect.getBuilderDescription(builderConf).toPromise();
147-
const targetOptionArray = await parseJsonSchemaToOptions(this._registry, builderDesc.schema);
148-
const overrides = parseArguments(options['--'] || [], targetOptionArray);
149-
150-
if (overrides['--']) {
151-
(overrides['--'] || []).forEach(additional => {
152-
this.logger.warn(`Unknown option: '${additional.split(/=/)[0]}'`);
153-
});
154-
155-
return 1;
156-
}
157-
const realBuilderConf = this._architect.getBuilderConfiguration({ ...targetSpec, overrides });
158-
159-
return this._architect.run(realBuilderConf, { logger: this._logger }).pipe(
160-
map((buildEvent: BuildEvent) => buildEvent.success ? 0 : 1),
161-
).toPromise();
162-
};
164+
const extra = options['--'] || [];
163165

164166
try {
165167
const targetSpec = this._makeTargetSpecifier(options);
166168
if (!targetSpec.project && this.target) {
167169
// This runs each target sequentially.
168170
// Running them in parallel would jumble the log messages.
169171
return await from(this.getProjectNamesByTarget(this.target)).pipe(
170-
concatMap(project => from(runSingleTarget({ ...targetSpec, project }))),
172+
concatMap(project => from(this.runSingleTarget({ ...targetSpec, project }, extra))),
171173
toArray(),
172174
map(results => results.every(res => res === 0) ? 0 : 1),
173175
)
174176
.toPromise();
175177
} else {
176-
return await runSingleTarget(targetSpec);
178+
return await this.runSingleTarget(targetSpec, extra);
177179
}
178180
} catch (e) {
179181
if (e instanceof schema.SchemaValidationException) {

0 commit comments

Comments
 (0)