Skip to content

Commit 20f45f9

Browse files
committed
feat: support puppeteer v5
1 parent 771d327 commit 20f45f9

File tree

4 files changed

+150
-83
lines changed

4 files changed

+150
-83
lines changed

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ notifications:
55
email: false
66
node_js:
77
- v14
8-
- v12
98
- v10
109
env:
1110
- PPTR_OVERRIDE_VERSION=1.6.x
1211
- PPTR_OVERRIDE_VERSION=1.8.x
1312
- PPTR_OVERRIDE_VERSION=1.12.x
13+
- PPTR_OVERRIDE_VERSION=2.x.x
14+
- PPTR_OVERRIDE_VERSION=3.x.x
15+
- PPTR_OVERRIDE_VERSION=4.x.x
16+
- PPTR_OVERRIDE_VERSION=5.x.x
1417
- PPTR_OVERRIDE_VERSION=latest
1518
before_install:
1619
- npm install -g yarn coveralls nyc @patrickhulce/scripts

lib/extend.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,26 @@ function requireOrUndefined(path: string): any {
1313
}
1414

1515
try {
16-
Page = require('puppeteer/lib/Page.js') // tslint:disable-line
16+
const libPrefix = requireOrUndefined(`puppeteer/lib/cjs/puppeteer/common/Page.js`)
17+
? 'puppeteer/lib/cjs/puppeteer/common'
18+
: 'puppeteer/lib'
19+
20+
Page = requireOrUndefined(`${libPrefix}/Page.js`) // tslint:disable-line
1721
if (Page.Page) Page = Page.Page
1822

19-
ElementHandle = requireOrUndefined('puppeteer/lib/ElementHandle.js') // tslint:disable-line variable-name
23+
ElementHandle = requireOrUndefined(`${libPrefix}/ElementHandle.js`) // tslint:disable-line variable-name
2024
if (ElementHandle && ElementHandle.ElementHandle) ElementHandle = ElementHandle.ElementHandle
2125

2226
if (!ElementHandle) {
23-
const ExecutionContext = requireOrUndefined('puppeteer/lib/ExecutionContext.js') // tslint:disable-line variable-name
27+
const ExecutionContext = requireOrUndefined(`${libPrefix}/ExecutionContext.js`) // tslint:disable-line variable-name
2428
if (ExecutionContext && ExecutionContext.ElementHandle) {
2529
ElementHandle = ExecutionContext.ElementHandle
2630
}
2731
}
2832
if (ElementHandle && ElementHandle.ElementHandle) ElementHandle = ElementHandle.ElementHandle
2933

3034
if (!ElementHandle) {
31-
const JSHandle = require('puppeteer/lib/JSHandle.js') // tslint:disable-line
35+
const JSHandle = require(`${libPrefix}/JSHandle.js`) // tslint:disable-line
3236
if (JSHandle && JSHandle.ElementHandle) {
3337
ElementHandle = JSHandle.ElementHandle
3438
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"@types/puppeteer": "^2.0.0",
6969
"generate-export-aliases": "^1.1.0",
7070
"jest": "^25.1.0",
71-
"puppeteer": "^2.0.0",
71+
"puppeteer": "^5.2.1",
7272
"rollup": "^2.0.3",
7373
"ts-jest": "^25.2.1",
7474
"tslint": "^6.0.0",

0 commit comments

Comments
 (0)