$ show remy/nodemon
nodemon is a CLI tool and library that monitors a directory for file changes and automatically restarts a specified command (typically a Node.js application). It parses command-line arguments and configuration files (nodemon.json, package.json) to determine watch paths, ignore patterns, file extensions, and the command to execute. It uses chokidar for file system watching and manages child processes via fork or spawn. When changes are detected, it matches the changed files against configured rules and restarts the child process if appropriate. It supports custom signals, delay, legacy polling, and event hooks. The architecture is monolithic with a library API, key modules include CLI parser, config loader, rule engine, file watcher, and process manager. The codebase relies on non-standard Node.js APIs (e.g., process.stdin.setEncoding, child_process.fork, process.versions.node), indicating significant technical drift from standard Node.js, though the tool remains widely used and actively maintained.
The LLM identified 2 files worth highlighting for reuse:
Provides a deep merge function that combines two objects, handling arrays, objects, and empty values correctly. It is self-contained (only depends on clone.js which can be inlined) and demonstrates a robust pattern for merging configuration objects. The function respects existing values, merges missing ones, and handles type mismatches gracefully.
Implements a file matching algorithm that sorts rules by specificity, applies ignore/watch logic using minimatch, and filters by extension. It handles relative paths, dotfiles, and Windows case-insensitivity. The core logic is self-contained (only imports one internal utility module) and could be extracted for use in other file monitoring tools. It demonstrates non-obvious skill in rule prioritization and efficient matching.