From d02644f7c41150709795e57bfd40351b4da35a7b Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Sat, 23 Apr 2022 01:59:21 +0200 Subject: Preload safe debug shim (#29) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In https://github.com/ferdium/ferdium-app/pull/23 we removed usages of the debug package due to an electron bug. This patch aims to restore some debug functionality by introducing a shim. The shim detect whether if it is being introduced in a preload script where the electron but would be triggered, and falls back to a simple replacement for debug. However, in the main and renderer processes, where a preload script is not being used, we still get full debug functionality. In this way, a module can be used both in a preload script and outside of it, while still preserving debug functionality whenever possible. Signed-off-by: Kristóf Marussy --- src/electron/Settings.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/electron/Settings.ts') diff --git a/src/electron/Settings.ts b/src/electron/Settings.ts index 0956ea486..de010b9a3 100644 --- a/src/electron/Settings.ts +++ b/src/electron/Settings.ts @@ -2,7 +2,7 @@ import { observable, toJS } from 'mobx'; import { pathExistsSync, outputJsonSync, readJsonSync } from 'fs-extra'; import { userDataPath } from '../environment-remote'; -const debug = require('debug')('Ferdium:Settings'); +const debug = require('../preload-safe-debug')('Ferdium:Settings'); export default class Settings { type = ''; -- cgit v1.2.3-54-g00ecf