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:
Jacob Richman
2025-11-20 10:44:02 -08:00
committed by GitHub
parent e20d282088
commit d1e35f8660
82 changed files with 1523 additions and 868 deletions
+17
View File
@@ -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();