@chengyixu/filewatch-cli
v1.0.0
Published
Watch files for changes and run commands automatically. Lightweight, zero-dependency file watcher with glob support, debouncing, process restart, and colorful output.
Maintainers
Readme
filewatch-cli
Watch files for changes and run commands automatically. Lightweight, zero-dependency file watcher with glob support, debouncing, process restart, and colorful output.
Uses native fs.watch — no chokidar or other heavy dependencies.
Install
npm install -g filewatch-cliUsage
# Watch TypeScript files and run tests
filewatch "src/**/*.ts" -- npm test
# Watch multiple patterns
filewatch "src/**" "test/**" -- npm run build
# Custom debounce (default 300ms)
filewatch "src/**/*.ts" --debounce 500 -- npm test
# Run command immediately on start, then watch
filewatch "src/**/*.ts" --initial -- npm test
# Clear terminal on each change
filewatch "src/**/*.ts" --clear -- npm test
# Restart long-running processes (kills previous before re-running)
filewatch "src/**" --restart -- node server.js
# Ignore additional patterns (node_modules, .git, dist ignored by default)
filewatch "**/*.css" --ignore build --ignore tmp -- npm run stylesOptions
| Option | Alias | Description |
|---|---|---|
| --debounce <ms> | -d | Debounce delay in milliseconds (default: 300) |
| --initial | -i | Run command immediately on start |
| --clear | -c | Clear terminal on each change |
| --restart | -r | Kill previous process before re-running |
| --ignore <pattern> | | Add ignore pattern (repeatable) |
| --help | -h | Show help |
| --version | -v | Show version |
Features
- Glob patterns —
*,**,?,{a,b},[abc] - Debouncing — configurable delay to batch rapid changes
- Process restart — kills previous process before starting new one (great for servers)
- Initial run — optionally run command before watching
- Clear screen — clean output on each change
- Changed file display — shows which file triggered the re-run
- Colorful timestamps — easy to scan output
- Zero dependencies — only
fs.watchunder the hood - Cross-platform — macOS, Linux, Windows
License
MIT
