From 16fd32a5f8829bee7b39eda25882d73c936b6b63 Mon Sep 17 00:00:00 2001 From: Tim van Dam Date: Sat, 7 Dec 2024 10:09:26 -0800 Subject: [PATCH] support inlined process.env.DEBUG Some browser-like environments do not support localStorage nor process.env, but can be provided environment variables because they automatically get inlined (i.e. process.env.XYZ gets replaced by whatever value XYZ is during a build step). This change supports this scenario without breaking previous behavior. --- src/browser.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/browser.js b/src/browser.js index df8e179e..fd96b65e 100644 --- a/src/browser.js +++ b/src/browser.js @@ -225,9 +225,12 @@ function load() { // XXX (@Qix-) should we be logging these? } - // If debug isn't set in LS, and we're in Electron, try to load $DEBUG - if (!r && typeof process !== 'undefined' && 'env' in process) { - r = process.env.DEBUG; + if (!r) { + try { + r = process.env.DEBUG; + } catch (error) { + // Swallow + } } return r;