// the find
mikeal/watch
Utilities for watching file trees in node.js
A file tree watcher for Node.js that wraps `fs.watchFile` with recursive directory walking and an EventEmitter-based monitor API. It predates the native `fs.watch`/`chokidar` era and has been effectively unmaintained since 2013 despite occasional dependency bumps. If you need something to watch files in Node, you almost certainly want chokidar instead.
The `createMonitor` EventEmitter API is clean — `created`, `changed`, `removed` events with stat objects cover the common cases without ceremony. The filter option accepting a plain function is flexible and doesn't force you into glob patterns. The CLI is genuinely useful for simple watch-and-run tasks in one line without pulling in a task runner.
Polling via `fs.watchFile` under the hood means it's slow and hammers the disk on large trees — this is a fundamental design choice, not a fixable bug. No support for `fs.watch` (inotify/FSEvents), so you get no near-instant notifications. Last real commit was around 2013; chokidar solves all of this and is actively maintained. The callback signature for `watchTree` — where `null, null` means 'I finished initializing' — is a footgun that bites everyone on first use.