mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 21:32:56 -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 outputFormat = config?.getOutputFormat();
|
||||||
const forceToStderr = outputFormat === 'json' || config === undefined;
|
const forceToStderr = outputFormat === 'json';
|
||||||
|
|
||||||
coreEvents.drainBacklogs(
|
coreEvents.drainBacklogs(
|
||||||
<K extends keyof CoreEvents>(event: K, args: CoreEvents[K]) => {
|
<K extends keyof CoreEvents>(event: K, args: CoreEvents[K]) => {
|
||||||
|
|||||||
@@ -69,16 +69,16 @@ describe('Output Redirection', () => {
|
|||||||
expect(writeToStderr).not.toHaveBeenCalled();
|
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
|
// Simulate buffered output during early init
|
||||||
coreEvents.emitOutput(false, 'early init message');
|
coreEvents.emitOutput(false, 'early init message');
|
||||||
|
|
||||||
// Initialize with undefined config
|
// Initialize with undefined config
|
||||||
initializeOutputListenersAndFlush(undefined);
|
initializeOutputListenersAndFlush(undefined);
|
||||||
|
|
||||||
// Verify it was forced to stderr
|
// Verify it went to stdout (default behavior)
|
||||||
expect(writeToStderr).toHaveBeenCalledWith('early init message', undefined);
|
expect(writeToStdout).toHaveBeenCalledWith('early init message', undefined);
|
||||||
expect(writeToStdout).not.toHaveBeenCalled();
|
expect(writeToStderr).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should attach ConsoleLog and UserFeedback listeners even if Output already has one', () => {
|
it('should attach ConsoleLog and UserFeedback listeners even if Output already has one', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user