本文根据 Devhints / Watchexec 翻译。代码示例及版本范围沿用原文。原文标注更新日期:2017-10-18。
mattgreen/watchexec 在特定文件发生更改时执行命令。
安装
OSX
brew install watchexec
Rust
cargo install watchexec
针对Linux 和 Windows,可从此处获取 当文件发生更改时,GitHub 会执行.
入门
watchexec --exts js,jsx -- npm test
运行 npm test 当 js,jsx 文件发生更改时。
watchman -w lib -w test -- npm test
运行 npm test 当 lib/ 以及 test/ 文件发生更改时。
其他选项 (Other options)
标志
-c --clear | 清屏 |
-r --restart | 如果 process 仍在运行,则将其重启 |
选项
-s --signal SIGKILL | 使用的终止信号 |
-d --debounce MS | 防抖(延迟)时间 MS 毫秒 |
-e --exts EXTS | 扩展名 |
-i --ignore PATTERN | 忽略这些文件 |
-w --watch PATH | 监视这些目录 |
另请参阅
- mattgreen/watchexec (github.com)