From b11fdb8ef54e86950b3306692343e4081aaed5bc Mon Sep 17 00:00:00 2001 From: Jack Franklin Date: Tue, 16 Jun 2020 12:17:00 +0100 Subject: [PATCH] Use our debug wrapper rather than Node's `debug`. --- src/BrowserFetcher.ts | 2 +- src/Connection.ts | 2 +- src/Debug.ts | 4 ++-- src/helper.ts | 2 +- src/launcher/BrowserRunner.ts | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/BrowserFetcher.ts b/src/BrowserFetcher.ts index 3fd2d72dc9ad8..11b063cabec62 100644 --- a/src/BrowserFetcher.ts +++ b/src/BrowserFetcher.ts @@ -23,7 +23,7 @@ import * as https from 'https'; import * as http from 'http'; import extractZip from 'extract-zip'; -import debug from 'debug'; +import { debug } from './Debug'; import removeRecursive from 'rimraf'; import * as URL from 'url'; import ProxyAgent from 'https-proxy-agent'; diff --git a/src/Connection.ts b/src/Connection.ts index a2b28fa97fe61..a8c99fd967684 100644 --- a/src/Connection.ts +++ b/src/Connection.ts @@ -15,7 +15,7 @@ */ import { assert } from './assert'; import { Events } from './Events'; -import debug from 'debug'; +import { debug } from './Debug'; const debugProtocolSend = debug('puppeteer:protocol:SEND ►'); const debugProtocolReceive = debug('puppeteer:protocol:RECV ◀'); diff --git a/src/Debug.ts b/src/Debug.ts index d494cbedff2e7..ad4ad8ab56c21 100644 --- a/src/Debug.ts +++ b/src/Debug.ts @@ -14,6 +14,8 @@ * limitations under the License. */ +const isNodeEnv = typeof document === 'undefined'; + /** * A debug function that can be used in any environment. * @@ -32,8 +34,6 @@ * ``` */ export const debug = (prefix: string): ((...args: unknown[]) => void) => { - const isNodeEnv = typeof document === 'undefined'; - if (isNodeEnv) { // eslint-disable-next-line @typescript-eslint/no-var-requires return require('debug')(prefix); diff --git a/src/helper.ts b/src/helper.ts index 03b4a8c634334..bc2f58163c341 100644 --- a/src/helper.ts +++ b/src/helper.ts @@ -14,7 +14,7 @@ * limitations under the License. */ import { TimeoutError } from './Errors'; -import debug from 'debug'; +import { debug } from './Debug'; import * as fs from 'fs'; import { CDPSession } from './Connection'; import { promisify } from 'util'; diff --git a/src/launcher/BrowserRunner.ts b/src/launcher/BrowserRunner.ts index 03ea2becbc78b..80dcac38d3c69 100644 --- a/src/launcher/BrowserRunner.ts +++ b/src/launcher/BrowserRunner.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import debug from 'debug'; +import { debug } from '../Debug'; import removeFolder from 'rimraf'; import * as childProcess from 'child_process';