fix(cli): allow early stdout when config is undefined (#26453)

This commit is contained in:
Coco Sheng
2026-05-04 13:48:24 -04:00
committed by GitHub
parent 165efa8a38
commit 37edd1d4df
2 changed files with 5 additions and 5 deletions
+1 -1
View File
@@ -830,7 +830,7 @@ export function initializeOutputListenersAndFlush(config?: Config) {
}
const outputFormat = config?.getOutputFormat();
const forceToStderr = outputFormat === 'json' || config === undefined;
const forceToStderr = outputFormat === 'json';
coreEvents.drainBacklogs(
<K extends keyof CoreEvents>(event: K, args: CoreEvents[K]) => {
+4 -4
View File
@@ -69,16 +69,16 @@ describe('Output Redirection', () => {
expect(writeToStderr).not.toHaveBeenCalled();
});
it('should force stdout to stderr when config is undefined (early failure)', () => {
it('should NOT force stdout to stderr when config is undefined (early init/version)', () => {
// Simulate buffered output during early init
coreEvents.emitOutput(false, 'early init message');
// Initialize with undefined config
initializeOutputListenersAndFlush(undefined);
// Verify it was forced to stderr
expect(writeToStderr).toHaveBeenCalledWith('early init message', undefined);
expect(writeToStdout).not.toHaveBeenCalled();
// Verify it went to stdout (default behavior)
expect(writeToStdout).toHaveBeenCalledWith('early init message', undefined);
expect(writeToStderr).not.toHaveBeenCalled();
});
it('should attach ConsoleLog and UserFeedback listeners even if Output already has one', () => {