fix(core): update

This commit is contained in:
Philipp Kunz 2019-11-15 18:59:29 +01:00
parent f110320dae
commit 64cd7cd75d
4 changed files with 328 additions and 443 deletions

738
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -13,16 +13,16 @@
"format": "(gitzone format)" "format": "(gitzone format)"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.0.22", "@gitzone/tsbuild": "^2.1.17",
"@gitzone/tstest": "^1.0.15", "@gitzone/tstest": "^1.0.28",
"@pushrocks/tapbundle": "^3.0.7", "@pushrocks/tapbundle": "^3.0.13",
"@types/node": "^10.11.7", "@types/node": "^12.12.7",
"tslint": "^5.11.0", "tslint": "^5.20.1",
"tslint-config-prettier": "^1.15.0" "tslint-config-prettier": "^1.15.0"
}, },
"dependencies": { "dependencies": {
"@types/puppeteer": "^1.12.4", "@types/puppeteer": "^1.20.2",
"puppeteer": "^1.17.0" "puppeteer": "^2.0.0"
}, },
"files": [ "files": [
"ts/*", "ts/*",

View File

@ -2,7 +2,9 @@ import { expect, tap } from '@pushrocks/tapbundle';
import * as smartpuppeteer from '../ts/index'; import * as smartpuppeteer from '../ts/index';
tap.test('first test', async () => { tap.test('first test', async () => {
const headlessBrowser = await smartpuppeteer.getEnvAwareBrowserInstance(); const headlessBrowser = await smartpuppeteer.getEnvAwareBrowserInstance({
forceNoSandbox: true
});
await headlessBrowser.close(); await headlessBrowser.close();
}); });

View File

@ -1,8 +1,19 @@
import puppeteer from 'puppeteer'; import puppeteer from 'puppeteer';
export const getEnvAwareBrowserInstance = async (): Promise<puppeteer.Browser> => { export interface IEnvAwareOptions {
forceNoSandbox?: boolean;
}
export const getEnvAwareBrowserInstance = async (optionsArg: IEnvAwareOptions = {}): Promise<puppeteer.Browser> => {
const options: IEnvAwareOptions = {
...{
forceNoSandbox: false
},
...optionsArg
}
let chromeArgs: string[] = []; let chromeArgs: string[] = [];
if (process.env.CI) { if (process.env.CI || options.forceNoSandbox) {
chromeArgs = chromeArgs.concat(['--no-sandbox', '--disable-setuid-sandbox']); chromeArgs = chromeArgs.concat(['--no-sandbox', '--disable-setuid-sandbox']);
} }
const headlessBrowser = await puppeteer.launch({ const headlessBrowser = await puppeteer.launch({