Skip to content

Commit

Permalink
fix: respect CHROME_PATH from environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Oct 16, 2020
1 parent 9130cf1 commit 6873117
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/find-chrome.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import fs from 'fs'

const { CHROME_PATH } = process.env

const paths: string[] =
process.platform === 'darwin'
? [
CHROME_PATH,
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
'/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary',
'/Applications/Chromium.app/Contents/MacOS/Chromium',
Expand All @@ -13,6 +16,7 @@ const paths: string[] =
]
: process.platform === 'win32'
? [
CHROME_PATH,
process.env.LOCALAPPDATA + '/Google/Chrome/Application/chrome.exe',
process.env.PROGRAMFILES + '/Google/Chrome/Application/chrome.exe',
process.env['PROGRAMFILES(X86)'] +
Expand All @@ -22,6 +26,7 @@ const paths: string[] =
process.env['PROGRAMFILES(X86)'] + '/Chromium/Application/chrome.exe',
]
: [
CHROME_PATH,
'/usr/bin/google-chrome-stable',
'/usr/bin/google-chrome',
'/usr/bin/chromium',
Expand All @@ -31,7 +36,7 @@ const paths: string[] =

export function findChrome(): string {
for (const p of paths) {
if (fs.existsSync(p)) {
if (p && fs.existsSync(p)) {
return p
}
}
Expand Down

0 comments on commit 6873117

Please sign in to comment.