Skip to content
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

fix(@angular/cli): fix webdriver deep import on yarn #5057

Merged
merged 1 commit into from
Feb 27, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 20 additions & 4 deletions packages/@angular/cli/tasks/e2e.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as url from 'url';
import { stripIndents } from 'common-tags';

import { E2eTaskOptions } from '../commands/e2e';
import { CliConfig } from '../models/config';
Expand Down Expand Up @@ -38,10 +39,25 @@ export const E2eTask = Task.extend({
}

if (e2eTaskOptions.webdriverUpdate) {
// webdriver-manager can only be accessed via a deep import from within
// protractor/node_modules. A double deep import if you will.
const webdriverUpdate = requireProjectModule(projectRoot,
'protractor/node_modules/webdriver-manager/built/lib/cmds/update');
// The webdriver-manager update command can only be accessed via a deep import.
const webdriverDeepImport = 'webdriver-manager/built/lib/cmds/update';
let webdriverUpdate: any;

try {
// When using npm, webdriver is within protractor/node_modules.
webdriverUpdate = requireProjectModule(projectRoot,
`protractor/node_modules/${webdriverDeepImport}`);
} catch (e) {
try {
// When using yarn, webdriver is found as a root module.
webdriverUpdate = requireProjectModule(projectRoot, webdriverDeepImport);
} catch (e) {
throw new SilentError(stripIndents`
Cannot automatically find webdriver-manager to update.
Update webdriver-manager manually and run 'ng e2e --no-webdriver-update' instead.
`);
}
}
// run `webdriver-manager update --standalone false --gecko false --quiet`
// if you change this, update the command comment in prev line, and in `eject` task
promise = promise.then(() => webdriverUpdate.program.run({
Expand Down