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)"
|
"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/*",
|
||||||
|
@ -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();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
15
ts/index.ts
15
ts/index.ts
@ -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({
|
||||||
|
Loading…
Reference in New Issue
Block a user