mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 13:22:35 -07:00
fix(cli): allow early stdout when config is undefined (#26453)
This commit is contained in:
@@ -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]) => {
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user