$ show gajus/turbowatch
Turbowatch is a file change detector and task orchestrator for Node.js that provides a more capable alternative to tools like Nodemon. It watches specified directories for file changes and executes user-defined tasks in response, featuring debouncing to batch rapid changes, retry logic for failed tasks, interruptible tasks to cancel ongoing operations, and graceful shutdown handling. The architecture uses a pluggable backend system for file watching (supporting native FSWatcher on macOS, falling back to Chokidar elsewhere), with an event processing pipeline that deduplicates and distributes changes to relevant subscribers. Key entry points include the CLI (bin/turbowatch.ts) and programmatic API (src/watch.ts). The system relies on dependencies like chokidar, zx for process spawning, micromatch for pattern matching, and roarr for structured logging.
The LLM identified 2 files worth highlighting for reuse:
Implements robust process tree termination by first sending SIGTERM to all processes in the tree, then SIGKILL after a grace period if processes haven't exited. Handles edge cases like already-terminated processes and provides detailed logging. This component solves the non-trivial problem of reliably cleaning up child process hierarchies, which is essential for any application managing subprocesses. It could be extracted with minimal changes as it only depends on the 'find-process' and 'pidtree' packages plus a logger interface.
Evaluates a composable expression language inspired by Watchman, supporting logical operators (allof, anyof, not) and matching primitives (dirname, idirname, match, imatch) using micromatch for glob pattern matching. This implements a reusable predicate system for filtering file paths based on hierarchical and naming criteria. The recursive evaluation of expression trees demonstrates non-trivial functional programming principles. It could be easily extracted as it only depends on micromatch for matching logic and path for directory operations, with the Expression type being simple to replicate.