From bbbba7604f01163a9f790694ddb247d5ea6242f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20Bou=C3=A7as?= Date: Thu, 23 May 2024 14:01:41 +0100 Subject: [PATCH] fix: update config logger (#5658) --- packages/config/src/log/logger.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/config/src/log/logger.js b/packages/config/src/log/logger.js index 0a8929b57c..90e34abd27 100644 --- a/packages/config/src/log/logger.js +++ b/packages/config/src/log/logger.js @@ -3,6 +3,10 @@ import figures from 'figures' import { serializeObject } from './serialize.js' import { THEME } from './theme.js' +export const logsAreBuffered = (logs) => { + return logs !== undefined && 'stdout' in logs +} + // When the `buffer` option is true, we return logs instead of printing them // on the console. The logs are accumulated in a `logs` array variable. export const getBufferLogs = function ({ buffer }) { @@ -19,10 +23,14 @@ export const log = function (logs, string, { color } = {}) { const stringA = String(string).replace(EMPTY_LINES_REGEXP, EMPTY_LINE) const stringB = color === undefined ? stringA : color(stringA) - if (logs !== undefined) { - // `logs` is a stateful variable + if (logs && logs.outputFlusher) { + logs.outputFlusher.flush() + } + if (logsAreBuffered(logs)) { + // `logs` is a stateful variable logs.stderr.push(stringB) + return }