diff options
Diffstat (limited to 'src/preload-safe-debug.ts')
-rw-r--r-- | src/preload-safe-debug.ts | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/preload-safe-debug.ts b/src/preload-safe-debug.ts index 1136e93c1..d18dd8639 100644 --- a/src/preload-safe-debug.ts +++ b/src/preload-safe-debug.ts | |||
@@ -9,20 +9,22 @@ | |||
9 | * because they correspond to preload scripts. | 9 | * because they correspond to preload scripts. |
10 | */ | 10 | */ |
11 | module.exports = function debug(namespace: string): (...params: any[]) => void { | 11 | module.exports = function debug(namespace: string): (...params: any[]) => void { |
12 | if (typeof process === 'object' && | 12 | if ( |
13 | 'contextIsolated' in process && | 13 | typeof process === 'object' && |
14 | (process as unknown as { contextIsolated: string }).contextIsolated) { | 14 | 'contextIsolated' in process && |
15 | (process as unknown as { contextIsolated: string }).contextIsolated | ||
16 | ) { | ||
15 | // Only output debug messages to the console if debugging is requested. | 17 | // Only output debug messages to the console if debugging is requested. |
16 | // We don't reimplement the matching algorithm from `debug` and just dump all | 18 | // We don't reimplement the matching algorithm from `debug` and just dump all |
17 | // messages to the console if some form of `Ferdium` debugging is enabled. | 19 | // messages to the console if some form of `Ferdium` debugging is enabled. |
18 | if (process.env.DEBUG?.startsWith('Ferdium:')) { | 20 | if (process.env.DEBUG?.startsWith('Ferdium:')) { |
19 | return (...params) => console.debug(`[${namespace}]`, ...params); | 21 | return (...params) => console.debug(`[${namespace}]`, ...params); |
20 | } | 22 | } |
21 | return () => { }; | 23 | return () => {}; |
22 | } | 24 | } |
23 | /* | 25 | /* |
24 | eslint-disable-next-line global-require -- | 26 | eslint-disable-next-line global-require -- |
25 | This file contains a workaround for situations were global require is problematic. | 27 | This file contains a workaround for situations were global require is problematic. |
26 | */ | 28 | */ |
27 | return require('debug')(namespace); | 29 | return require('debug')(namespace); |
28 | } | 30 | }; |