Skip to content

Commit 8252f20

Browse files
Alanalexeagle
Alan
authored andcommitted
fix(@angular-devkit/build-angular): error when both baseUrl and devServerTarget are used in protractor
Users cannot use both baseUrl and devServerTarget, and the later superseeds the baseUrl. Fixes #13611
1 parent 7bc2e39 commit 8252f20

File tree

1 file changed

+10
-3
lines changed
  • packages/angular_devkit/build_angular/src/protractor

1 file changed

+10
-3
lines changed

packages/angular_devkit/build_angular/src/protractor/index.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,14 @@ export class ProtractorBuilder implements Builder<ProtractorBuilderOptions> {
4444
const options = builderConfig.options;
4545
const root = this.context.workspace.root;
4646
const projectRoot = resolve(root, builderConfig.root);
47-
// const projectSystemRoot = getSystemPath(projectRoot);
47+
48+
// ensure that either one of this option is used
49+
if (options.devServerTarget && options.baseUrl) {
50+
throw new Error(tags.stripIndents`
51+
The 'baseUrl' option cannot be used with 'devServerTarget'.
52+
When present, 'devServerTarget' will be used to automatically setup 'baseUrl' for Protractor.
53+
`);
54+
}
4855

4956
// TODO: verify using of(null) to kickstart things is a pattern.
5057
return of(null).pipe(
@@ -81,7 +88,7 @@ export class ProtractorBuilder implements Builder<ProtractorBuilderOptions> {
8188
}
8289

8390
// Compute baseUrl from devServerOptions.
84-
if (options.devServerTarget && builderConfig.options.publicHost) {
91+
if (builderConfig.options.publicHost) {
8592
let publicHost = builderConfig.options.publicHost;
8693
if (!/^\w+:\/\//.test(publicHost)) {
8794
publicHost = `${builderConfig.options.ssl
@@ -90,7 +97,7 @@ export class ProtractorBuilder implements Builder<ProtractorBuilderOptions> {
9097
}
9198
const clientUrl = url.parse(publicHost);
9299
baseUrl = url.format(clientUrl);
93-
} else if (options.devServerTarget) {
100+
} else {
94101
const result: DevServerResult | undefined = buildEvent.result;
95102

96103
baseUrl = url.format({

0 commit comments

Comments
 (0)