ファイル変更時にコマンド実行(watchmedo, watchexec)
watchmedo (watchdog)
watchmedo shell-command -R --command 'make build' ./src# プロセスが動いていても停止して再実行するwatchmedo auto-restart -R -d ./src -- make serve
watchmedo インストール
pip3 install watchdog[watchmedo]==2.1.3
※ 2.1.4 on Ubuntuはバグがありそう
Exception in thread Thread-1:Traceback (most recent call last):File "$HOME/.pyenv/versions/3.9.6/lib/python3.9/threading.py", line 973, in _bootstrap_innerself.run()File "$HOME/.pyenv/versions/3.9.6/lib/python3.9/site-packages/watchdog/observers/api.py", line 199, in runself.dispatch_events(self.event_queue, self.timeout)File "$HOME/.pyenv/versions/3.9.6/lib/python3.9/site-packages/watchdog/observers/api.py", line 372, in dispatch_eventshandler.dispatch(event)File "$HOME/.pyenv/versions/3.9.6/lib/python3.9/site-packages/watchdog/events.py", line 282, in dispatchself.event_dispatch_map[event.event_type](event)AttributeError: 'RootHandler' object has no attribute 'event_dispatch_map'
watchexec
- https://github.com/watchexec/watchexec
- https://crates.io/crates/watchexec-cli
- https://superuser.com/questions/181517/how-to-execute-a-command-whenever-a-file-changes
watchexec -w ./src -- make build# プロセスが動いていても停止して再実行するwatchexec -r -w ./src -- make serve# 初回実行しないwatchexec -p -w ./src -- make event-trigger
watchexec インストール
Rustのインストール
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh