Something went wrong. Try again.
fork of prime agent with changes i want but are not upstreamable probqbly (and some fixes)
Something went wrong. Try again.
573 B · 30 lines
TypeScript
at main
12345678910111213141516171819202122232425262728293031import { type FSWatcher, type WatchListener, watch } from "node:fs";
export const FS_WATCH_RETRY_DELAY_MS = 5000;
export function closeWatcher(watcher: FSWatcher | null | undefined): void { if (!watcher) { return; }
try { watcher.close(); } catch { // Ignore watcher close errors }}
export function watchWithErrorHandler( path: string, listener: WatchListener<string>, onError: () => void,): FSWatcher | null { try { const watcher = watch(path, listener); watcher.on("error", onError); return watcher; } catch { onError(); return null; }}