From f10218f9d5df7bacdd21fbde4ca55b0ea9f6029e Mon Sep 17 00:00:00 2001 From: eps1lon Date: Fri, 5 Jul 2024 11:05:29 +0200 Subject: [PATCH] Access `process` only if defined --- src/pretty-dom.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pretty-dom.js b/src/pretty-dom.js index f4382bcd..14c5f772 100644 --- a/src/pretty-dom.js +++ b/src/pretty-dom.js @@ -7,7 +7,7 @@ import {getConfig} from './config' const shouldHighlight = () => { // Try to safely parse env COLORS: We will default behavior if any step fails. try { - const colors = process?.env?.COLORS + const colors = typeof process !== 'undefined' ? process?.env?.COLORS : undefined if (colors) { const b = JSON.parse(colors) if (typeof b === 'boolean') return b @@ -18,7 +18,7 @@ const shouldHighlight = () => { // In all other cases, whether COLORS was a weird type, or the attempt threw: // Fall back to colorizing if we are running in node. - return !!process?.versions?.node + return typeof process !== 'undefined' && !!process.versions?.node } const {DOMCollection} = prettyFormat.plugins