From 6ef17303a74058817e42227705d6b3727b134b0d Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Thu, 25 Jan 2018 23:06:18 +0800 Subject: [PATCH] errors: only init colors when util is not loaded PR-URL: https://github.com/nodejs/node/pull/18359 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig --- lib/internal/errors.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/internal/errors.js b/lib/internal/errors.js index 5a3aaa04e97a09..6a52d55bb84247 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -270,12 +270,14 @@ class AssertionError extends Error { if (message != null) { super(message); } else { - const util = lazyUtil(); - if (process.stdout.isTTY && process.stdout.getColorDepth() !== 1) { + if (util_ === null && + process.stdout.isTTY && + process.stdout.getColorDepth() !== 1) { green = '\u001b[32m'; white = '\u001b[39m'; red = '\u001b[31m'; } + const util = lazyUtil(); if (actual && actual.stack && actual instanceof Error) actual = `${actual.name}: ${actual.message}`;