Skip to content

Commit

Permalink
Fix chrome finder on linux/osx when process.env isn't populated (Goog…
Browse files Browse the repository at this point in the history
  • Loading branch information
wardpeet authored and paulirish committed Jul 19, 2017
1 parent d3c9343 commit 0e4652e
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions chrome-finder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 0e4652e

Please sign in to comment.