Remove unused readdir import, simplify rmdir loop
This commit is contained in:
parent
385673f420
commit
e8318f68b0
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user