Skip to content

Commit 43fff13

Browse files
alan-agius4vikerman
authored andcommitted
fix(@angular/cli): cannot use same target name in when having multiple projects (#12327)
Closes #12320
1 parent f74c1f4 commit 43fff13

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

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

+6-3
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,13 @@ export abstract class ArchitectCommand<
103103

104104
if (this.target) {
105105
// Add options IF there's only one builder of this kind.
106-
const projectNames = this.getProjectNamesByTarget(this.target);
106+
const targetSpec: TargetSpecifier = this._makeTargetSpecifier(options);
107+
const projectNames = targetSpec.project
108+
? [targetSpec.project]
109+
: this.getProjectNamesByTarget(this.target);
110+
107111
const builderConfigurations: BuilderConfiguration[] = [];
108112
for (const projectName of projectNames) {
109-
const targetSpec: TargetSpecifier = this._makeTargetSpecifier(options);
110113
const targetDesc = this._architect.getBuilderConfiguration({
111114
project: projectName,
112115
target: targetSpec.target,
@@ -207,7 +210,7 @@ export abstract class ArchitectCommand<
207210
// For multi target commands, we always list all projects that have the target.
208211
return allProjectsForTargetName;
209212
} else {
210-
// For single target commands, we try try the default project project first,
213+
// For single target commands, we try the default project first,
211214
// then the full list if it has a single project, then error out.
212215
const maybeDefaultProject = this._workspace.getDefaultProjectName();
213216
if (maybeDefaultProject && allProjectsForTargetName.includes(maybeDefaultProject)) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { expectFileToExist } from '../../utils/fs';
2+
import { ng } from '../../utils/process';
3+
import { updateJsonFile } from '../../utils/project';
4+
5+
export default async function () {
6+
await ng('generate', 'app', 'secondary-app');
7+
8+
await updateJsonFile('angular.json', workspaceJson => {
9+
workspaceJson.defaultProject = undefined;
10+
});
11+
12+
await ng('build', 'secondary-app');
13+
14+
expectFileToExist('dist/secondary-app/index.html');
15+
expectFileToExist('dist/secondary-app/main.js');
16+
}

0 commit comments

Comments
 (0)