From 112c2c7f0e79db87fe856d661652ec5c123e0f53 Mon Sep 17 00:00:00 2001 From: Ward Peeters Date: Thu, 20 Jul 2017 01:19:13 +0200 Subject: [PATCH] Fix chrome finder on linux/osx when process.env isn't populated (#2687) --- .travis.yml | 2 +- chrome-launcher/chrome-finder.ts | 25 +++++++++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 76dd5d7dc4d3..00d4a740b662 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,7 +27,7 @@ install: before_script: - gem install travis-artifacts - export DISPLAY=:99.0 - - export LIGHTHOUSE_CHROMIUM_PATH="$(pwd)/chrome-linux/chrome" + - export CHROME_PATH="$(pwd)/chrome-linux/chrome" - sh -e /etc/init.d/xvfb start - sleep 3 # wait for xvfb to boot - yarn build-all diff --git a/chrome-launcher/chrome-finder.ts b/chrome-launcher/chrome-finder.ts index 01c129246b36..6504b5fa57f8 100644 --- a/chrome-launcher/chrome-finder.ts +++ b/chrome-launcher/chrome-finder.ts @@ -53,11 +53,17 @@ export function darwin() { {regex: /^\/Applications\/.*Chrome Canary.app/, weight: 101}, {regex: /^\/Volumes\/.*Chrome.app/, weight: -2}, {regex: /^\/Volumes\/.*Chrome Canary.app/, weight: -1}, - {regex: new RegExp(process.env.LIGHTHOUSE_CHROMIUM_PATH), weight: 150}, - {regex: new RegExp(process.env.CHROME_PATH), weight: 151} ]; - // clang-format on + if (process.env.LIGHTHOUSE_CHROMIUM_PATH) { + priorities.push({regex: new RegExp(process.env.LIGHTHOUSE_CHROMIUM_PATH), weight: 150}); + } + + if (process.env.CHROME_PATH) { + priorities.push({regex: new RegExp(process.env.CHROME_PATH), weight: 151}); + } + + // clang-format on return sort(installations, priorities); } @@ -124,12 +130,19 @@ export function linux() { } const priorities: Priorities = [ - {regex: /chrome-wrapper$/, weight: 51}, {regex: /google-chrome-stable$/, weight: 50}, + {regex: /chrome-wrapper$/, weight: 51}, + {regex: /google-chrome-stable$/, weight: 50}, {regex: /google-chrome$/, weight: 49}, - {regex: new RegExp(process.env.LIGHTHOUSE_CHROMIUM_PATH), weight: 100}, - {regex: new RegExp(process.env.CHROME_PATH), weight: 101} ]; + if (process.env.LIGHTHOUSE_CHROMIUM_PATH) { + priorities.push({regex: new RegExp(process.env.LIGHTHOUSE_CHROMIUM_PATH), weight: 100}); + } + + if (process.env.CHROME_PATH) { + priorities.push({regex: new RegExp(process.env.CHROME_PATH), weight: 101}); + } + return sort(uniq(installations.filter(Boolean)), priorities); }