mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-16 21:10:40 -07:00
fix(cli): conditionally suppress console output in headless and non-interactive modes
This commit is contained in:
@@ -43,6 +43,26 @@ describe('ConsolePatcher', () => {
|
||||
console.error = originalError;
|
||||
});
|
||||
|
||||
it('should NOT suppress console.error even when suppressConsoleOutput is true', () => {
|
||||
const originalError = console.error;
|
||||
const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
||||
|
||||
patcher = new ConsolePatcher({
|
||||
debugMode: false,
|
||||
suppressConsoleOutput: true,
|
||||
stderr: true,
|
||||
});
|
||||
patcher.patch();
|
||||
|
||||
console.error('test error');
|
||||
|
||||
expect(errorSpy).toHaveBeenCalled();
|
||||
|
||||
patcher.cleanup();
|
||||
errorSpy.mockRestore();
|
||||
console.error = originalError;
|
||||
});
|
||||
|
||||
it('should NOT suppress output when suppressConsoleOutput is true but debugMode is true', () => {
|
||||
const originalError = console.error;
|
||||
const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
||||
|
||||
@@ -50,7 +50,11 @@ export class ConsolePatcher {
|
||||
private patchConsoleMethod =
|
||||
(type: 'log' | 'warn' | 'error' | 'debug' | 'info') =>
|
||||
(...args: unknown[]) => {
|
||||
if (this.params.suppressConsoleOutput && !this.params.debugMode) {
|
||||
if (
|
||||
this.params.suppressConsoleOutput &&
|
||||
!this.params.debugMode &&
|
||||
type !== 'error'
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user