Add support for Windows (#78)

* Add support for Windows

* Fix windows path
This commit is contained in:
Steven 2019-04-30 12:53:43 -04:00 committed by GitHub
parent adaa1b4204
commit b4f7625a22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -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;

View File

@ -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 = {