Commit 7826796b authored by Lawrence Onah's avatar Lawrence Onah

fix chrome executable path on linux

parent 87b168d2
import * as fs from 'fs'
import * as os from 'os'
import delay from 'delay' import delay from 'delay'
import { platform } from 'os'
import { import {
type Browser, type Browser,
type Page, type Page,
...@@ -137,15 +138,22 @@ export async function getBrowser(launchOptions?: PuppeteerLaunchOptions) { ...@@ -137,15 +138,22 @@ export async function getBrowser(launchOptions?: PuppeteerLaunchOptions) {
/** /**
* Get the correct path to chrome's executable * Get the correct path to chrome's executable
* defaults to the path for macOs
*/ */
const executablePath = (): string => { const executablePath = (): string => {
switch (platform()) { switch (os.platform()) {
case 'win32': case 'win32':
return 'C:\\ProgramFiles\\Google\\Chrome\\Application\\chrome.exe' return 'C:\\ProgramFiles\\Google\\Chrome\\Application\\chrome.exe'
case 'linux': case 'darwin':
return '/usr/bin/google-chrome-stable'
default:
return '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' return '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
default:
/**
* Since two (2) separate chrome releases exists on linux
* we first do a check to ensure we're executing the right one.
*/
const chromeExists = fs.existsSync('/usr/bin/google-chrome')
return chromeExists
? '/usr/bin/google-chrome'
: '/usr/bin/google-chrome-stable'
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment