Skip to content

Commit

Permalink
errors: only init colors when util is not loaded
Browse files Browse the repository at this point in the history
PR-URL: #18359
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
joyeecheung committed Jan 29, 2018
1 parent 3ec7921 commit 6ef1730
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Expand Down

0 comments on commit 6ef1730

Please sign in to comment.