Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const buildPuppeteerOptions = (
options: PuppeteerLaunchOptions,
device: Device
) => {
const launchOptions: PuppeteerLaunchOptions = {
args: [
"--disable-dev-shm-usage",
"--no-default-browser-check",
"--window-position=0,0",
`--window-size=${device.viewport.width + CONFIG.chromeOffsetX},${device
.viewport.height + CONFIG.chromeOffsetY}`
],
defaultViewport: null,
headless: CONFIG.headless,
...options
};
if (platform() === "linux") {
launchOptions!.args!.push("--disable-gpu");
launchOptions!.args!.push("--disable-setuid-sandbox");
launchOptions!.args!.push("--no-sandbox");
}
if (CONFIG.chromeExecutablePath) {
launchOptions.executablePath = CONFIG.chromeExecutablePath;
}
return launchOptions;
};