File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,14 @@ const args = process.argv.slice(2);
9
9
10
10
let browser ;
11
11
12
+ process . on ( 'unhandledRejection' , ( reason , promise ) => {
13
+ console . log ( 'Unhandled Promise rejection at' , promise , 'reason:' , reason ) ;
14
+ if ( browser ) {
15
+ browser . close ( ) . then ( ( ) => process . exit ( 1 ) ) ;
16
+ }
17
+ process . exit ( 1 ) ;
18
+ } ) ;
19
+
12
20
async function onerror ( err ) {
13
21
console . error ( err . stack ) ;
14
22
await browser . close ( ) ;
@@ -22,7 +30,11 @@ async function onerror(err) {
22
30
page . on ( 'error' , onerror ) ;
23
31
page . on ( 'pageerror' , onerror ) ;
24
32
25
- page . on ( 'console' , ( ...args ) => console . log ( 'PAGE LOG:' , ...args ) ) ;
33
+ page . on ( 'console' , msg => {
34
+ if ( msg . type ( ) !== 'clear' ) {
35
+ console . log ( 'PAGE LOG:' , msg . text ( ) ) ;
36
+ }
37
+ } ) ;
26
38
27
39
const url = / h t t p s ? / . test ( args [ 0 ] ) ? args [ 0 ] : `file://${ path . resolve ( args [ 0 ] ) } ` ;
28
40
await page . goto ( url ) ;
You can’t perform that action at this time.
0 commit comments