Skip to content

Commit c72c45f

Browse files
hanslalexeagle
authored andcommitted
fix(@angular/cli): only add options if theres only one builder configuration
1 parent 66fbc59 commit c72c45f

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

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

+30-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
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-
import { Architect, BuildEvent, TargetSpecifier } from '@angular-devkit/architect';
8+
import {
9+
Architect,
10+
BuildEvent,
11+
BuilderConfiguration,
12+
TargetSpecifier,
13+
} from '@angular-devkit/architect';
914
import { experimental, json, schema, tags } from '@angular-devkit/core';
1015
import { NodeJsSyncHost, createConsoleLogger } from '@angular-devkit/core/node';
1116
import { from } from 'rxjs';
@@ -88,11 +93,31 @@ export abstract class ArchitectCommand extends Command<ArchitectCommandOptions>
8893
throw new Error('Cannot determine project or target for Architect command.');
8994
}
9095

91-
const builderConf = this._architect.getBuilderConfiguration(targetSpec);
92-
const builderDesc = await this._architect.getBuilderDescription(builderConf).toPromise();
93-
const targetOptionArray = await parseJsonSchemaToOptions(this._registry, builderDesc.schema);
96+
if (this.target) {
97+
// Add options IF there's only one builder of this kind.
98+
const projectNames = this.getProjectNamesByTarget(this.target);
99+
const builderConfigurations: BuilderConfiguration[] = [];
100+
for (const projectName of projectNames) {
101+
const targetSpec: TargetSpecifier = this._makeTargetSpecifier(options);
102+
const targetDesc = this._architect.getBuilderConfiguration({
103+
project: projectName,
104+
target: targetSpec.target,
105+
});
106+
107+
if (!builderConfigurations.find(b => b.builder === targetDesc.builder)) {
108+
builderConfigurations.push(targetDesc);
109+
}
110+
}
111+
112+
if (builderConfigurations.length == 1) {
113+
const builderConf = builderConfigurations[0];
114+
const builderDesc = await this._architect.getBuilderDescription(builderConf).toPromise();
94115

95-
this.description.options.push(...targetOptionArray);
116+
this.description.options.push(...(
117+
await parseJsonSchemaToOptions(this._registry, builderDesc.schema)
118+
));
119+
}
120+
}
96121
}
97122

98123
async run(options: ArchitectCommandOptions) {

0 commit comments

Comments
 (0)