errors: only init colors when util is not loaded

PR-URL: https://github.com/nodejs/node/pull/18359
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Joyee Cheung 2018-01-25 23:06:18 +08:00
parent 3ec79216f9
commit 6ef17303a7
No known key found for this signature in database
GPG Key ID: F586868AAD831D0C

View File

@ -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}`;