Skip to content

Commit 3786efb

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

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/pretty-dom.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ 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 =
11+
typeof process !== 'undefined' ? process?.env?.COLORS : undefined
1112
if (colors) {
1213
const b = JSON.parse(colors)
1314
if (typeof b === 'boolean') return b
@@ -18,7 +19,7 @@ const shouldHighlight = () => {
1819

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

2425
const {DOMCollection} = prettyFormat.plugins

0 commit comments

Comments
 (0)