I am using npm run watch
to wath the react typescript project file changes and rebuild the source code, but sometimes the watch process will exit automatically when compile failed, I was wonder is it possible to minitor the npm process in macOS, when the npm run watch command exit, start the command automatically.
Add a comment
|
1 Answer
No need for an out-of-band monitoring solution; put the command in a loop to run infinitely.
In zsh or bash,
while true; do npm run watch; sleep 1; done
If npm run watch
exits, it will sleep 1s, then run the command again.