Skip to content

Commit e1e2cb9

Browse files
clydinalan-agius4
authored andcommitted
refactor(@angular/cli): use command default for unspecified target builders
If a target definition from a project's configuration does not contain a `builder` field and the CLI command provides a default, the default will now be used for the command execution. This is in addition to the existing case where the command will use a synthetic target definition for commands that provide default builders. (cherry picked from commit 744ae4e)
1 parent 107dcc8 commit e1e2cb9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/angular/cli/src/command-builder/architect-command-module.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,22 @@ export abstract class ArchitectCommandModule
4141
// Add default builder if target is not in project and a command default is provided
4242
if (this.findDefaultBuilderName && this.context.workspace) {
4343
for (const [project, projectDefinition] of this.context.workspace.projects) {
44-
if (projectDefinition.targets.has(target)) {
44+
const targetDefinition = projectDefinition.targets.get(target);
45+
if (targetDefinition?.builder) {
4546
continue;
4647
}
4748

4849
const defaultBuilder = await this.findDefaultBuilderName(projectDefinition, {
4950
project,
5051
target,
5152
});
52-
if (defaultBuilder) {
53+
if (!defaultBuilder) {
54+
continue;
55+
}
56+
57+
if (targetDefinition) {
58+
targetDefinition.builder = defaultBuilder;
59+
} else {
5360
projectDefinition.targets.set(target, {
5461
builder: defaultBuilder,
5562
});

0 commit comments

Comments
 (0)