Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ function styleText(format, text, { validateStream = true, stream = process.stdou
validateString(text, 'text');
validateBoolean(validateStream, 'options.validateStream');

let skipColorize;
if (validateStream) {
if (
!isReadableStream(stream) &&
Expand All @@ -134,9 +133,13 @@ function styleText(format, text, { validateStream = true, stream = process.stdou
}

// If the stream is falsy or should not be colorized, set skipColorize to true
skipColorize = !lazyUtilColors().shouldColorize(stream);
const skipColorize = !lazyUtilColors().shouldColorize(stream);
if (skipColorize) {
return text;
}
}


// If the format is not an array, convert it to an array
const formatArray = ArrayIsArray(format) ? format : [format];

Expand All @@ -148,14 +151,9 @@ function styleText(format, text, { validateStream = true, stream = process.stdou
if (formatCodes == null) {
validateOneOf(key, 'format', ObjectKeys(inspect.colors));
}
if (skipColorize) continue;
ArrayPrototypePush(codes, formatCodes);
}

if (skipColorize) {
return text;
}

// Build opening codes
let openCodes = '';
for (let i = 0; i < codes.length; i++) {
Expand Down
Loading