fix(core): update
This commit is contained in:
parent
f110320dae
commit
64cd7cd75d
738
package-lock.json
generated
738
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
14
package.json
14
package.json
@ -13,16 +13,16 @@
|
||||
"format": "(gitzone format)"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.0.22",
|
||||
"@gitzone/tstest": "^1.0.15",
|
||||
"@pushrocks/tapbundle": "^3.0.7",
|
||||
"@types/node": "^10.11.7",
|
||||
"tslint": "^5.11.0",
|
||||
"@gitzone/tsbuild": "^2.1.17",
|
||||
"@gitzone/tstest": "^1.0.28",
|
||||
"@pushrocks/tapbundle": "^3.0.13",
|
||||
"@types/node": "^12.12.7",
|
||||
"tslint": "^5.20.1",
|
||||
"tslint-config-prettier": "^1.15.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/puppeteer": "^1.12.4",
|
||||
"puppeteer": "^1.17.0"
|
||||
"@types/puppeteer": "^1.20.2",
|
||||
"puppeteer": "^2.0.0"
|
||||
},
|
||||
"files": [
|
||||
"ts/*",
|
||||
|
@ -2,7 +2,9 @@ import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import * as smartpuppeteer from '../ts/index';
|
||||
|
||||
tap.test('first test', async () => {
|
||||
const headlessBrowser = await smartpuppeteer.getEnvAwareBrowserInstance();
|
||||
const headlessBrowser = await smartpuppeteer.getEnvAwareBrowserInstance({
|
||||
forceNoSandbox: true
|
||||
});
|
||||
await headlessBrowser.close();
|
||||
});
|
||||
|
||||
|
15
ts/index.ts
15
ts/index.ts
@ -1,8 +1,19 @@
|
||||
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[] = [];
|
||||
if (process.env.CI) {
|
||||
if (process.env.CI || options.forceNoSandbox) {
|
||||
chromeArgs = chromeArgs.concat(['--no-sandbox', '--disable-setuid-sandbox']);
|
||||
}
|
||||
const headlessBrowser = await puppeteer.launch({
|
||||
|
Loading…
Reference in New Issue
Block a user