监视文件变化并运行命令,支持重启、过滤和忽略规则
watchexec 监听目录/文件变化并执行命令,支持扩展名过滤、重启子进程、忽略规则和事件合并。它比 entr 更偏向“持续开发服务器/测试”场景。
watchexec -e py -- pytest -q
watchexec -r -e go -- go run ./cmd/app
watchexec -w src -e rs -- cargo test
watchexec --ignore target -- make
-w 缩小范围,避免 node_modules/.git 等噪音。-r 重启子进程,--stop-timeout 控制优雅退出;长任务要配合。-e 是扩展名过滤,不是 glob;复杂匹配用 --filter 或忽略规则。.gitignore 是否被尊重,必要时显式 --ignore。--debounce/--on-busy-update 调整。