feat: M1 companion 資料層與 band 角色行
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
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 []
|
||||
}
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user