Skip to content

Commit 6ef1730

Browse files
committed
errors: only init colors when util is not loaded
PR-URL: #18359 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 3ec7921 commit 6ef1730

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/internal/errors.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,12 +270,14 @@ class AssertionError extends Error {
270270
if (message != null) {
271271
super(message);
272272
} else {
273-
const util = lazyUtil();
274-
if (process.stdout.isTTY && process.stdout.getColorDepth() !== 1) {
273+
if (util_ === null &&
274+
process.stdout.isTTY &&
275+
process.stdout.getColorDepth() !== 1) {
275276
green = '\u001b[32m';
276277
white = '\u001b[39m';
277278
red = '\u001b[31m';
278279
}
280+
const util = lazyUtil();
279281

280282
if (actual && actual.stack && actual instanceof Error)
281283
actual = `${actual.name}: ${actual.message}`;

0 commit comments

Comments
 (0)