refactor: migrate src/cli/cmd/session.ts from Bun.file() to statSync (#14144)

This commit is contained in:
Dax
2026-02-18 16:20:58 -05:00
committed by GitHub
parent a2469d933e
commit e37a9081a6
3 changed files with 14 additions and 11 deletions

View File

@@ -18,12 +18,13 @@ export namespace Filesystem {
}
}
export function stat(p: string): ReturnType<typeof statSync> | undefined {
return statSync(p, { throwIfNoEntry: false }) ?? undefined
}
export async function size(p: string): Promise<number> {
try {
return statSync(p).size
} catch {
return 0
}
const s = stat(p)?.size ?? 0
return typeof s === "bigint" ? Number(s) : s
}
export async function readText(p: string): Promise<string> {