mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-15 18:13:38 +08:00
feat(@angular/cli): allow overrides on multi-target if builder is same
It makes sense and is the only way to allow "ng lint --fix". If the builder is the same for all targets, overrides are allowed.
This commit is contained in:
parent
14357e30c0
commit
c45e778687
@ -11,7 +11,14 @@ import {
|
||||
BuilderDescription,
|
||||
TargetSpecifier,
|
||||
} from '@angular-devkit/architect';
|
||||
import { JsonObject, UnknownException, experimental, schema, strings } from '@angular-devkit/core';
|
||||
import {
|
||||
JsonObject,
|
||||
UnknownException,
|
||||
experimental,
|
||||
schema,
|
||||
strings,
|
||||
tags,
|
||||
} from '@angular-devkit/core';
|
||||
import { NodeJsSyncHost, createConsoleLogger } from '@angular-devkit/core/node';
|
||||
import { of } from 'rxjs';
|
||||
import { from } from 'rxjs';
|
||||
@ -88,8 +95,29 @@ export abstract class ArchitectCommand extends Command<ArchitectCommandOptions>
|
||||
const projectNames = this.getProjectNamesByTarget(this.target);
|
||||
const { overrides } = this._makeTargetSpecifier(options);
|
||||
if (projectNames.length > 1 && Object.keys(overrides || {}).length > 0) {
|
||||
throw new Error('Architect commands with multiple targets cannot specify overrides.'
|
||||
+ `'${this.target}' would be run on the following projects: ${projectNames.join()}`);
|
||||
// Verify that all builders are the same, otherwise error out (since the meaning of an
|
||||
// option could vary from builder to builder).
|
||||
|
||||
const builders: string[] = [];
|
||||
for (const projectName of projectNames) {
|
||||
const targetSpec: TargetSpecifier = this._makeTargetSpecifier(options);
|
||||
const targetDesc = this._architect.getBuilderConfiguration({
|
||||
project: projectName,
|
||||
target: targetSpec.target,
|
||||
});
|
||||
|
||||
if (builders.indexOf(targetDesc.builder) == -1) {
|
||||
builders.push(targetDesc.builder);
|
||||
}
|
||||
}
|
||||
|
||||
if (builders.length > 1) {
|
||||
throw new Error(tags.oneLine`
|
||||
Architect commands with command line overrides cannot target different builders. The
|
||||
'${this.target}' target would run on projects ${projectNames.join()} which have the
|
||||
following builders: ${'\n ' + builders.join('\n ')}
|
||||
`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user