refactor: statusbar、companion、herdr 外掛改名加上 jsc- 前綴
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
f10b168c28
commit
58e2b2d26a
@@ -0,0 +1,26 @@
|
||||
import type { Fs } from './fs'
|
||||
|
||||
// hooks 沙箱沒有 node:fs,改用引擎的 $.fs;它沒有 rename,所以不提供(writeAtomic 會直接覆寫)
|
||||
type EngineFs = {
|
||||
read(path: string): Promise<string>
|
||||
write(path: string, text: string): Promise<void>
|
||||
list(path?: string): Promise<{ name: string }[]>
|
||||
}
|
||||
|
||||
export const engineFs = (fs: EngineFs): Fs => ({
|
||||
async read(path) {
|
||||
try {
|
||||
return await fs.read(path)
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
},
|
||||
write: (path, data) => fs.write(path, data),
|
||||
async list(dir) {
|
||||
try {
|
||||
return (await fs.list(dir)).map(e => e.name).filter(n => !n.endsWith('.tmp')).sort()
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user