From cfe8eab054c0c74c341421f5a5a3db3377d17b61 Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Sat, 21 Feb 2026 08:53:06 -0800 Subject: [PATCH] add `vm uncache` command to clear the package cache --- src/commands/vm.ts | 8 ++++++++ src/vm.ts | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/src/commands/vm.ts b/src/commands/vm.ts index 789d2a8..3277280 100644 --- a/src/commands/vm.ts +++ b/src/commands/vm.ts @@ -71,4 +71,12 @@ export function register(program: Command) { await vm.destroy() console.log("✔ VM destroyed") }) + + vmCmd + .command("uncache") + .description("Clear the package cache (next create will re-download)") + .action(async () => { + const had = await vm.clearCache() + console.log(had ? "✔ Package cache cleared" : "No cache to clear") + }) } diff --git a/src/vm.ts b/src/vm.ts index 46c85d8..adee6f1 100644 --- a/src/vm.ts +++ b/src/vm.ts @@ -337,3 +337,10 @@ export async function destroy(): Promise { await stop() await $`container delete ${CONTAINER_NAME}`.nothrow().quiet() } + +/** Clear the package cache so the next create re-downloads everything. */ +export async function clearCache(): Promise { + const exists = await Bun.file(join(CACHE_DIR, 'bun')).exists() + await $`rm -rf ${CACHE_DIR}`.nothrow().quiet() + return exists +}