clean up watch.sh

This commit is contained in:
Brian Hicks 2019-04-02 15:44:28 -05:00
parent 1966878cbc
commit 45bafa7bba

View File

@ -3,18 +3,17 @@ set -euo pipefail
if ! test -d public; then make public; fi
declare SERVER_PID
# wait for an interrupt and kill both of them
cleanup() {
if ! test -z "$SERVER_PID"; then kill "$SERVER_PID"; fi
}
trap cleanup EXIT INT
# start a web server
./script/serve.sh public &
SERVER_PID=$!
# start a watcher
find src styleguide-app -type f -not -ipath '*elm-stuff*' | entr make public &
WATCHER_PID=$!
# wait for an interrupt and kill both of them
cleanup() {
kill $SERVER_PID $WATCHER_PID
}
trap cleanup EXIT INT
while : ; do sleep 10; done
# start a watcher. This loops forever, so we don't need to loop ourselves.
find src styleguide-app -type f -not -ipath '*elm-stuff*' | entr -c -p make public