import { mkdir, readdir, readFile, rename, writeFile } from 'node:fs/promises' import { dirname } from 'node:path' import type { Fs } from './fs' export const nodeFs: Fs = { async read(path) { try { return await readFile(path, 'utf8') } catch { return null } }, async write(path, data) { await mkdir(dirname(path), { recursive: true }) await writeFile(path, data, 'utf8') }, rename, async list(dir) { try { return (await readdir(dir)).filter(n => !n.endsWith('.tmp')).sort() } catch { return [] } }, }