Add support for Windows (#78)
* Add support for Windows * Fix windows path
This commit is contained in:
parent
adaa1b4204
commit
b4f7625a22
|
@ -1,12 +1,12 @@
|
|||
import { launch, Page } from 'puppeteer-core';
|
||||
import { getOptions as getLaunchOptions } from './options';
|
||||
import { getOptions } from './options';
|
||||
let _page: Page | null;
|
||||
|
||||
async function getPage(isDev: boolean) {
|
||||
if (_page) {
|
||||
return _page;
|
||||
}
|
||||
const options = await getLaunchOptions(isDev);
|
||||
const options = await getOptions(isDev);
|
||||
const browser = await launch(options);
|
||||
_page = await browser.newPage();
|
||||
return _page;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import chrome from 'chrome-aws-lambda';
|
||||
const exePath = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
|
||||
const exePath = process.platform === 'win32'
|
||||
? 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'
|
||||
: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
|
||||
|
||||
interface Options {
|
||||
args: string[];
|
||||
|
@ -13,7 +15,7 @@ export async function getOptions(isDev: boolean) {
|
|||
options = {
|
||||
args: [],
|
||||
executablePath: exePath,
|
||||
headless: true,
|
||||
headless: true
|
||||
};
|
||||
} else {
|
||||
options = {
|
||||
|
|
Loading…
Reference in New Issue