|
1 | 1 | import * as url from 'url';
|
| 2 | +import { stripIndents } from 'common-tags'; |
2 | 3 |
|
3 | 4 | import { E2eTaskOptions } from '../commands/e2e';
|
4 | 5 | import { CliConfig } from '../models/config';
|
@@ -38,10 +39,25 @@ export const E2eTask = Task.extend({
|
38 | 39 | }
|
39 | 40 |
|
40 | 41 | if (e2eTaskOptions.webdriverUpdate) {
|
41 |
| - // webdriver-manager can only be accessed via a deep import from within |
42 |
| - // protractor/node_modules. A double deep import if you will. |
43 |
| - const webdriverUpdate = requireProjectModule(projectRoot, |
44 |
| - 'protractor/node_modules/webdriver-manager/built/lib/cmds/update'); |
| 42 | + // The webdriver-manager update command can only be accessed via a deep import. |
| 43 | + const webdriverDeepImport = 'webdriver-manager/built/lib/cmds/update'; |
| 44 | + let webdriverUpdate: any; |
| 45 | + |
| 46 | + try { |
| 47 | + // When using npm, webdriver is within protractor/node_modules. |
| 48 | + webdriverUpdate = requireProjectModule(projectRoot, |
| 49 | + `protractor/node_modules/${webdriverDeepImport}`); |
| 50 | + } catch (e) { |
| 51 | + try { |
| 52 | + // When using yarn, webdriver is found as a root module. |
| 53 | + webdriverUpdate = requireProjectModule(projectRoot, webdriverDeepImport); |
| 54 | + } catch (e) { |
| 55 | + throw new SilentError(stripIndents` |
| 56 | + Cannot automatically find webdriver-manager to update. |
| 57 | + Update webdriver-manager manually and run 'ng e2e --no-webdriver-update' instead. |
| 58 | + `); |
| 59 | + } |
| 60 | + } |
45 | 61 | // run `webdriver-manager update --standalone false --gecko false --quiet`
|
46 | 62 | // if you change this, update the command comment in prev line, and in `eject` task
|
47 | 63 | promise = promise.then(() => webdriverUpdate.program.run({
|
|
0 commit comments