Skip to content

Commit f10218f

Browse files
committed
Access process only if defined
1 parent 76cb73d commit f10218f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/pretty-dom.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {getConfig} from './config'
77
const shouldHighlight = () => {
88
// Try to safely parse env COLORS: We will default behavior if any step fails.
99
try {
10-
const colors = process?.env?.COLORS
10+
const colors = typeof process !== 'undefined' ? process?.env?.COLORS : undefined
1111
if (colors) {
1212
const b = JSON.parse(colors)
1313
if (typeof b === 'boolean') return b
@@ -18,7 +18,7 @@ const shouldHighlight = () => {
1818

1919
// In all other cases, whether COLORS was a weird type, or the attempt threw:
2020
// Fall back to colorizing if we are running in node.
21-
return !!process?.versions?.node
21+
return typeof process !== 'undefined' && !!process.versions?.node
2222
}
2323

2424
const {DOMCollection} = prettyFormat.plugins

0 commit comments

Comments
 (0)