Skip to content

Commit 63d2996

Browse files
committed
fixup! lib: optimize styleText when validateStream is false
1 parent 5f9c663 commit 63d2996

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/util.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ function styleText(format, text, options) {
183183
}
184184
validateBoolean(validateStream, 'options.validateStream');
185185

186+
let skipColorize;
186187
if (validateStream) {
187188
const stream = options?.stream ?? process.stdout;
188189
if (
@@ -192,8 +193,7 @@ function styleText(format, text, options) {
192193
) {
193194
throw new ERR_INVALID_ARG_TYPE('stream', ['ReadableStream', 'WritableStream', 'Stream'], stream);
194195
}
195-
const skipColorize = !lazyUtilColors().shouldColorize(stream);
196-
if (skipColorize) return text;
196+
skipColorize = !lazyUtilColors().shouldColorize(stream);
197197
}
198198

199199
const isArray = ArrayIsArray(format);
@@ -215,6 +215,8 @@ function styleText(format, text, options) {
215215
processedText = replaceCloseCode(processedText, style.closeSeq, style.openSeq, style.keepClose);
216216
}
217217

218+
if (skipColorize) return text;
219+
218220
return `${openCodes}${processedText}${closeCodes}`;
219221
}
220222

0 commit comments

Comments
 (0)