From 7567f5c09295fbf2cc20aa577357d474618d7dfa Mon Sep 17 00:00:00 2001 From: Meligy Date: Wed, 22 Feb 2017 23:54:55 +1100 Subject: [PATCH] fix(eject): set ejected project to run `webdriver-manager update` as part of `e2e` npm script Closes #4920 --- packages/@angular/cli/tasks/e2e.ts | 1 + packages/@angular/cli/tasks/eject.ts | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/packages/@angular/cli/tasks/e2e.ts b/packages/@angular/cli/tasks/e2e.ts index 824c245cd7a5..2c11b2fbf70f 100644 --- a/packages/@angular/cli/tasks/e2e.ts +++ b/packages/@angular/cli/tasks/e2e.ts @@ -43,6 +43,7 @@ export const E2eTask = Task.extend({ const webdriverUpdate = requireProjectModule(projectRoot, 'protractor/node_modules/webdriver-manager/built/lib/cmds/update'); // 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({ standalone: false, gecko: false, diff --git a/packages/@angular/cli/tasks/eject.ts b/packages/@angular/cli/tasks/eject.ts index 61cf807d5592..ab0057945ec8 100644 --- a/packages/@angular/cli/tasks/eject.ts +++ b/packages/@angular/cli/tasks/eject.ts @@ -31,6 +31,8 @@ const ProgressPlugin = require('webpack/lib/ProgressPlugin'); export const pluginArgs = Symbol('plugin-args'); export const postcssArgs = Symbol('postcss-args'); +const pree2eNpmScript = `webdriver-manager update --standalone false --gecko false --quiet`; + class JsonWebpackSerializer { public imports: {[name: string]: string[]} = {}; @@ -434,6 +436,12 @@ export default Task.extend({ Your package.json scripts needs to not contain a start script as it will be overwritten. `); } + if (scripts['pree2e'] && scripts['pree2e'] !== pree2eNpmScript && !force) { + throw new SilentError(oneLine` + Your package.json scripts needs to not contain a pree2e script as it will be + overwritten. + `); + } if (scripts['e2e'] && scripts['e2e'] !== 'ng e2e' && !force) { throw new SilentError(oneLine` Your package.json scripts needs to not contain a e2e script as it will be overwritten. @@ -448,6 +456,7 @@ export default Task.extend({ packageJson['scripts']['build'] = 'webpack'; packageJson['scripts']['start'] = 'webpack-dev-server'; packageJson['scripts']['test'] = 'karma start ./karma.conf.js'; + packageJson['scripts']['pree2e'] = pree2eNpmScript; packageJson['scripts']['e2e'] = 'protractor ./protractor.conf.js'; // Add new dependencies based on our dependencies.