From 4442e893c367a901a4c801816e0ade5b78c291c9 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Sat, 12 Jul 2025 15:42:47 -0700 Subject: fix(auth): Remove sharp edges from headless auth (#3985) --- packages/cli/src/utils/cleanup.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'packages/cli/src/utils') diff --git a/packages/cli/src/utils/cleanup.ts b/packages/cli/src/utils/cleanup.ts index 4011ae30..628b881c 100644 --- a/packages/cli/src/utils/cleanup.ts +++ b/packages/cli/src/utils/cleanup.ts @@ -8,6 +8,23 @@ import { promises as fs } from 'fs'; import { join } from 'path'; import { getProjectTempDir } from '@google/gemini-cli-core'; +const cleanupFunctions: Array<() => void> = []; + +export function registerCleanup(fn: () => void) { + cleanupFunctions.push(fn); +} + +export function runExitCleanup() { + for (const fn of cleanupFunctions) { + try { + fn(); + } catch (_) { + // Ignore errors during cleanup. + } + } + cleanupFunctions.length = 0; // Clear the array +} + export async function cleanupCheckpoints() { const tempDir = getProjectTempDir(process.cwd()); const checkpointsDir = join(tempDir, 'checkpoints'); -- cgit v1.2.3