chore: use puppeteer-core (#4929)

This commit is contained in:
Pooya Parsa 2019-02-03 10:06:01 +03:30 committed by GitHub
parent cdec133cb3
commit 940a36fd65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 18 deletions

View File

@ -147,8 +147,6 @@ jobs:
test-types: test-types:
<<: *defaults <<: *defaults
docker:
- image: circleci/node:latest-browsers
steps: steps:
- checkout - checkout
- attach_workspace: - attach_workspace:

View File

@ -62,7 +62,7 @@
"node-fetch": "^2.3.0", "node-fetch": "^2.3.0",
"pug": "^2.0.3", "pug": "^2.0.3",
"pug-plain-loader": "^1.0.0", "pug-plain-loader": "^1.0.0",
"puppeteer": "~1.11.0", "puppeteer-core": "^1.12.1",
"request": "^2.88.0", "request": "^2.88.0",
"request-promise-native": "^1.0.5", "request-promise-native": "^1.0.5",
"rimraf": "^2.6.3", "rimraf": "^2.6.3",
@ -80,7 +80,8 @@
"tslint": "^5.12.1", "tslint": "^5.12.1",
"typescript": "^3.3.1", "typescript": "^3.3.1",
"vue-jest": "^3.0.2", "vue-jest": "^3.0.2",
"vue-property-decorator": "^7.3.0" "vue-property-decorator": "^7.3.0",
"which": "^1.3.1"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -1,17 +1,24 @@
import puppeteer from 'puppeteer' import puppeteer from 'puppeteer-core'
import which from 'which'
export default class Browser { export default class Browser {
async start(options = {}) { async start(options = {}) {
// https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions // https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions
this.browser = await puppeteer.launch( const _opts = {
Object.assign( args: [
{ '--no-sandbox',
args: ['--no-sandbox', '--disable-setuid-sandbox'], '--disable-setuid-sandbox'
executablePath: process.env.PUPPETEER_EXECUTABLE_PATH ],
}, executablePath: process.env.PUPPETEER_EXECUTABLE_PATH,
options ...options
) }
)
if (!_opts.executablePath) {
const resolve = cmd => which.sync(cmd, { nothrow: true })
_opts.executablePath = resolve('google-chrome') || resolve('chromium')
}
this.browser = await puppeteer.launch(_opts)
} }
async close() { async close() {

View File

@ -9231,10 +9231,10 @@ punycode@^2.1.0, punycode@^2.1.1:
resolved "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" resolved "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==
puppeteer@~1.11.0: puppeteer-core@^1.12.1:
version "1.11.0" version "1.12.1"
resolved "https://registry.npmjs.org/puppeteer/-/puppeteer-1.11.0.tgz#63cdbe12b07275cd6e0b94bce41f3fcb20305770" resolved "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-1.12.1.tgz#aec39d9c199ceff6ddd4da00e0733bb73fce4156"
integrity sha512-iG4iMOHixc2EpzqRV+pv7o3GgmU2dNYEMkvKwSaQO/vMZURakwSOn/EYJ6OIRFYOque1qorzIBvrytPIQB3YzQ== integrity sha512-arGXPRe1dkX3+tOh1GMQ0Ny3CoOCRurkHAW4AZEBIBMX/LdY6ReFqRTT9YSV3d9zzxiIat9kJc3v9h9nkxAu3g==
dependencies: dependencies:
debug "^4.1.0" debug "^4.1.0"
extract-zip "^1.6.6" extract-zip "^1.6.6"