Skip to content

Commit

Permalink
Access process only if defined
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Jul 5, 2024
1 parent 76cb73d commit f10218f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/pretty-dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit f10218f

Please sign in to comment.