From e8318f68b0a9185f73df034f737c4d7bac98b008 Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Mon, 9 Mar 2026 12:49:13 -0700 Subject: [PATCH] Remove unused readdir import, simplify rmdir loop --- src/commands/helpers.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/commands/helpers.ts b/src/commands/helpers.ts index fbb45fa..922ca75 100644 --- a/src/commands/helpers.ts +++ b/src/commands/helpers.ts @@ -1,6 +1,6 @@ import { basename, dirname, join } from "path" import { homedir } from "os" -import { mkdir, readdir, rmdir, symlink, unlink } from "fs/promises" +import { mkdir, rmdir, symlink, unlink } from "fs/promises" import { $ } from "bun" import * as git from "../git.ts" import * as vm from "../vm.ts" @@ -18,9 +18,8 @@ export async function unlinkSessionSymlink(root: string, branch: string): Promis // Walk up from the symlink's parent, removing empty dirs, stopping at .sandlot/ itself let dir = dirname(symlinkPath) while (dir !== sandlotDir) { - const entries = await readdir(dir).catch(() => null) - if (!entries || entries.length > 0) break - await rmdir(dir).catch(() => {}) + const ok = await rmdir(dir).then(() => true, () => false) + if (!ok) break dir = dirname(dir) } }