Skip to content

Commit

Permalink
Add support for Windows 64bit chrome install path
Browse files Browse the repository at this point in the history
  • Loading branch information
neg4n committed Jul 29, 2022
1 parent fe8dbdf commit c01a743
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { NextApiHandler, NextApiRequest, NextApiResponse } from 'next'
import type { NextApiRequest, NextApiResponse } from 'next'
import type { Except, RequireExactlyOne } from 'type-fest'
import type { Page, Viewport } from 'puppeteer-core'
import type { ReactElement } from 'react'
import { renderToStaticMarkup } from 'react-dom/server'
import os from 'os'
import deepMerge from 'deepmerge'
import twemoji from 'twemoji'
import core from 'puppeteer-core'
Expand Down Expand Up @@ -226,12 +227,19 @@ function pipe(...functions: Array<Function>): () => Promise<BrowserEnvironment>
}

function getChromiumExecutable(browserEnvironment: BrowserEnvironment) {
const executable =
process.platform === 'win32'
? 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'
: process.platform === 'linux'
? '/usr/bin/google-chrome'
: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
let executable = null

if (process.platform === 'win32') {
if (['arm64', 'ppc64', 'x64', 's390x'].includes(os.arch())) {
executable = 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe'
} else {
executable = 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'
}
} else if (process.platform === 'linux') {
executable = '/usr/bin/google-chrome'
} else {
executable = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
}

return { ...browserEnvironment, executable }
}
Expand Down

0 comments on commit c01a743

Please sign in to comment.