Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): error when both baseUrl and `de…
Browse files Browse the repository at this point in the history
…vServerTarget` are used in protractor

Users cannot use both baseUrl and devServerTarget, and the later superseeds the baseUrl.

Fixes #13611
  • Loading branch information
Alan authored and alexeagle committed Feb 9, 2019
1 parent 7bc2e39 commit 8252f20
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/angular_devkit/build_angular/src/protractor/index.ts
Expand Up @@ -44,7 +44,14 @@ export class ProtractorBuilder implements Builder<ProtractorBuilderOptions> {
const options = builderConfig.options;
const root = this.context.workspace.root;
const projectRoot = resolve(root, builderConfig.root);
// const projectSystemRoot = getSystemPath(projectRoot);

// ensure that either one of this option is used
if (options.devServerTarget && options.baseUrl) {
throw new Error(tags.stripIndents`
The 'baseUrl' option cannot be used with 'devServerTarget'.
When present, 'devServerTarget' will be used to automatically setup 'baseUrl' for Protractor.
`);
}

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

// Compute baseUrl from devServerOptions.
if (options.devServerTarget && builderConfig.options.publicHost) {
if (builderConfig.options.publicHost) {
let publicHost = builderConfig.options.publicHost;
if (!/^\w+:\/\//.test(publicHost)) {
publicHost = `${builderConfig.options.ssl
Expand All @@ -90,7 +97,7 @@ export class ProtractorBuilder implements Builder<ProtractorBuilderOptions> {
}
const clientUrl = url.parse(publicHost);
baseUrl = url.format(clientUrl);
} else if (options.devServerTarget) {
} else {
const result: DevServerResult | undefined = buildEvent.result;

baseUrl = url.format({
Expand Down

0 comments on commit 8252f20

Please sign in to comment.