From 3595cee14df2713500f2f996a52a10908b4a80e4 Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Thu, 6 Feb 2020 10:07:06 -0500 Subject: [PATCH] fix(@angular-devkit/build-angular): resolve webdriver-manager from protractor location The webdriver-manager package is a direct dependency of protractor. The only guaranteed method to resolve the webdriver-manager package in this case is to resolve it from a base of the protractor location. --- .../build_angular/src/protractor/index.ts | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/packages/angular_devkit/build_angular/src/protractor/index.ts b/packages/angular_devkit/build_angular/src/protractor/index.ts index 48195442de3a..f04de786c20d 100644 --- a/packages/angular_devkit/build_angular/src/protractor/index.ts +++ b/packages/angular_devkit/build_angular/src/protractor/index.ts @@ -39,21 +39,15 @@ function runProtractor(root: string, options: ProtractorBuilderOptions): Promise async function updateWebdriver() { // The webdriver-manager update command can only be accessed via a deep import. const webdriverDeepImport = 'webdriver-manager/built/lib/cmds/update'; - const importOptions = [ - // When using npm, webdriver is within protractor/node_modules. - `protractor/node_modules/${webdriverDeepImport}`, - // When using yarn, webdriver is found as a root module. - webdriverDeepImport, - ]; let path; - for (const importOption of importOptions) { - try { - path = require.resolve(importOption); - } catch (error) { - if (error.code !== 'MODULE_NOT_FOUND') { - throw error; - } + try { + const protractorPath = require.resolve('protractor'); + + path = require.resolve(webdriverDeepImport, { paths: [protractorPath] }); + } catch (error) { + if (error.code !== 'MODULE_NOT_FOUND') { + throw error; } }