summaryrefslogtreecommitdiff
path: root/packages/cli/src/utils/cleanup.ts
diff options
context:
space:
mode:
authorN. Taylor Mullen <[email protected]>2025-07-12 15:42:47 -0700
committerGitHub <[email protected]>2025-07-12 15:42:47 -0700
commit4442e893c367a901a4c801816e0ade5b78c291c9 (patch)
treea5962bb7e5995e33306bd33635f25f889f5c4b52 /packages/cli/src/utils/cleanup.ts
parent890982a811e22de9525148e6c28f39bfbf10a49a (diff)
fix(auth): Remove sharp edges from headless auth (#3985)
Diffstat (limited to 'packages/cli/src/utils/cleanup.ts')
-rw-r--r--packages/cli/src/utils/cleanup.ts17
1 files changed, 17 insertions, 0 deletions
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');