Skip to content

Commit 3d8b21a

Browse files
joyeecheungMayaLekova
authored andcommitted
errors: only init colors when util is not loaded
PR-URL: nodejs#18359 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent b564255 commit 3d8b21a

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)