ignore: add file status command

This commit is contained in:
Dax Raad
2025-07-01 20:39:43 -04:00
parent c68aeed8d9
commit 7e5941e14b
3 changed files with 122 additions and 28 deletions

View File

@@ -22,28 +22,30 @@ export namespace FileWatcher {
"file.watcher",
() => {
const app = App.use()
const watcher = fs.watch(
app.info.path.cwd,
{ recursive: true },
(event, file) => {
log.info("change", { file, event })
if (!file) return
// for some reason async local storage is lost here
// https://github.com/oven-sh/bun/issues/20754
App.provideExisting(app, async () => {
Bus.publish(Event.Updated, {
file,
event,
try {
const watcher = fs.watch(
app.info.path.cwd,
{ recursive: true },
(event, file) => {
log.info("change", { file, event })
if (!file) return
// for some reason async local storage is lost here
// https://github.com/oven-sh/bun/issues/20754
App.provideExisting(app, async () => {
Bus.publish(Event.Updated, {
file,
event,
})
})
})
},
)
return {
watcher,
},
)
return { watcher }
} finally {
return {}
}
},
async (state) => {
state.watcher.close()
state.watcher?.close()
},
)()
}