Skip to content

fix(@angular/cli): cannot use same target name in when having multiple projects #12327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/angular/cli/models/architect-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,13 @@ export abstract class ArchitectCommand<

if (this.target) {
// Add options IF there's only one builder of this kind.
const projectNames = this.getProjectNamesByTarget(this.target);
const targetSpec: TargetSpecifier = this._makeTargetSpecifier(options);
const projectNames = targetSpec.project
? [targetSpec.project]
: this.getProjectNamesByTarget(this.target);

const builderConfigurations: BuilderConfiguration[] = [];
for (const projectName of projectNames) {
const targetSpec: TargetSpecifier = this._makeTargetSpecifier(options);
const targetDesc = this._architect.getBuilderConfiguration({
project: projectName,
target: targetSpec.target,
Expand Down Expand Up @@ -207,7 +210,7 @@ export abstract class ArchitectCommand<
// For multi target commands, we always list all projects that have the target.
return allProjectsForTargetName;
} else {
// For single target commands, we try try the default project project first,
// For single target commands, we try the default project first,
// then the full list if it has a single project, then error out.
const maybeDefaultProject = this._workspace.getDefaultProjectName();
if (maybeDefaultProject && allProjectsForTargetName.includes(maybeDefaultProject)) {
Expand Down
16 changes: 16 additions & 0 deletions tests/legacy-cli/e2e/tests/misc/multiple-targets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { expectFileToExist } from '../../utils/fs';
import { ng } from '../../utils/process';
import { updateJsonFile } from '../../utils/project';

export default async function () {
await ng('generate', 'app', 'secondary-app');

await updateJsonFile('angular.json', workspaceJson => {
workspaceJson.defaultProject = undefined;
});

await ng('build', 'secondary-app');

expectFileToExist('dist/secondary-app/index.html');
expectFileToExist('dist/secondary-app/main.js');
}