Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix chrome finder on linux & osx #2687

Merged
merged 3 commits into from
Jul 19, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions chrome-launcher/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 @@ -107,8 +113,7 @@ export function linux() {
];
executables.forEach((executable: string) => {
try {
const chromePath =
execFileSync('which', [executable]).toString().split(newLineRegex)[0];
const chromePath = execFileSync('which', [executable]).toString().split(newLineRegex)[0];

if (canAccess(chromePath)) {
installations.push(chromePath);
Expand All @@ -127,10 +132,16 @@ export function linux() {
const priorities: Priorities = [
{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