mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-30 15:04:16 -07:00
Protect stdout and stderr so JavaScript code can't accidentally write to stdout corrupting ink rendering (#13247)
Bypassing rules as link checker failure is spurious.
This commit is contained in:
@@ -9,12 +9,29 @@ import { join } from 'node:path';
|
||||
import { Storage } from '@google/gemini-cli-core';
|
||||
|
||||
const cleanupFunctions: Array<(() => void) | (() => Promise<void>)> = [];
|
||||
const syncCleanupFunctions: Array<() => void> = [];
|
||||
|
||||
export function registerCleanup(fn: (() => void) | (() => Promise<void>)) {
|
||||
cleanupFunctions.push(fn);
|
||||
}
|
||||
|
||||
export function registerSyncCleanup(fn: () => void) {
|
||||
syncCleanupFunctions.push(fn);
|
||||
}
|
||||
|
||||
export function runSyncCleanup() {
|
||||
for (const fn of syncCleanupFunctions) {
|
||||
try {
|
||||
fn();
|
||||
} catch (_) {
|
||||
// Ignore errors during cleanup.
|
||||
}
|
||||
}
|
||||
syncCleanupFunctions.length = 0;
|
||||
}
|
||||
|
||||
export async function runExitCleanup() {
|
||||
runSyncCleanup();
|
||||
for (const fn of cleanupFunctions) {
|
||||
try {
|
||||
await fn();
|
||||
|
||||
Reference in New Issue
Block a user