[ide-mode] Close all open diffs when the CLI gets closed (#5792)

This commit is contained in:
christine betts
2025-08-08 15:38:30 +00:00
committed by GitHub
parent 5ec4ea9b4d
commit 3af4913ef3
7 changed files with 126 additions and 7 deletions

View File

@@ -8,16 +8,16 @@ import { promises as fs } from 'fs';
import { join } from 'path';
import { getProjectTempDir } from '@google/gemini-cli-core';
const cleanupFunctions: Array<() => void> = [];
const cleanupFunctions: Array<(() => void) | (() => Promise<void>)> = [];
export function registerCleanup(fn: () => void) {
export function registerCleanup(fn: (() => void) | (() => Promise<void>)) {
cleanupFunctions.push(fn);
}
export function runExitCleanup() {
export async function runExitCleanup() {
for (const fn of cleanupFunctions) {
try {
fn();
await fn();
} catch (_) {
// Ignore errors during cleanup.
}