Skip to content

fix(@angular-devkit/build-angular): error when both baseUrl and devServerTarget are used in protractor #13614

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 3 commits into from
Feb 9, 2019
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
2 changes: 1 addition & 1 deletion packages/angular_devkit/build_angular/src/browser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class BrowserBuilder implements Builder<BrowserBuilderSchema> {
) {
// Ensure Build Optimizer is only used with AOT.
if (options.buildOptimizer && !options.aot) {
throw new Error('The `--build-optimizer` option cannot be used without `--aot`.');
throw new Error(`The 'buildOptimizer' option cannot be used without 'aot'.`);
}

let wco: WebpackConfigOptions<NormalizedBrowserBuilderSchema>;
Expand Down
13 changes: 10 additions & 3 deletions packages/angular_devkit/build_angular/src/protractor/index.ts
Original file line number Diff line number Diff line change
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) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is never called when options.devServerTarget is falsy

concatMap(() => options.devServerTarget ? this._startDevServer(options) : of(null)),

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
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
},
"baseUrl": {
"type": "string",
"description": "Base URL for protractor to connect to."
"description": "Base URL for protractor to connect to.",
"x-deprecated": "Use \"baseUrl\" in the Protractor config file instead."
}
},
"additionalProperties": false,
Expand Down