Skip to content

Commit 09b85e1

Browse files
authored
Create options.ts
1 parent e0d4b54 commit 09b85e1

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

api/_lib/options.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import chrome from 'chrome-aws-lambda';
2+
const exePath = process.platform === 'win32'
3+
? 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'
4+
: process.platform === 'linux'
5+
? '/usr/bin/google-chrome'
6+
: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
7+
8+
interface Options {
9+
args: string[];
10+
executablePath: string;
11+
headless: boolean;
12+
}
13+
14+
export async function getOptions(isDev: boolean) {
15+
let options: Options;
16+
if (isDev) {
17+
options = {
18+
args: [],
19+
executablePath: exePath,
20+
headless: true
21+
};
22+
} else {
23+
options = {
24+
args: chrome.args,
25+
executablePath: await chrome.executablePath,
26+
headless: chrome.headless,
27+
};
28+
}
29+
return options;
30+
}

0 commit comments

Comments
 (0)