This commit is contained in:
parent
165e4ed60d
commit
70a1bb05d3
1 changed files with 8 additions and 18 deletions
|
@ -24,27 +24,17 @@ Basically just a golang `http.FileServer` that uses `Cache-Control: "no-cache, n
|
||||||
And something to run our build when files change. In the spirit of homebrewing boring stuff - I made `~/bin/make-watch`
|
And something to run our build when files change. In the spirit of homebrewing boring stuff - I made `~/bin/make-watch`
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
#!/usr/bin/env bash
|
inotifywait -r -m --exclude "${dir}/.git\/" -e modify -e create -e delete "$dir" | while read -r event; do
|
||||||
|
if [[ $last_run_seconds -eq 0 ]]; then
|
||||||
dir="$(pwd)"
|
make "$@"
|
||||||
if [[ -n "$1" ]]; then
|
last_run_seconds="$SECONDS"
|
||||||
dir="$1"
|
|
||||||
shift
|
|
||||||
fi
|
|
||||||
|
|
||||||
last_run_seconds=0
|
|
||||||
grace_seconds=1
|
|
||||||
inotifywait -r -m -e modify -e create -e delete "$dir" --format "%e" | while read -r event; do
|
|
||||||
if [[ $SECONDS -gt $((last_run_seconds + grace_seconds)) ]]; then
|
|
||||||
# reset last_run_seconds if enough time has elapsed
|
|
||||||
last_run_seconds=0
|
|
||||||
elif [[ $last_run_seconds -gt 0 ]] && [[ $SECONDS -le $((last_run_seconds + grace_seconds)) ]]; then
|
|
||||||
# do not consider a make run if seconds falls between the last run and grace period
|
|
||||||
continue;
|
continue;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
make "$@"
|
if [[ $SECONDS -ge $((last_run_seconds + grace_seconds)) ]]; then
|
||||||
last_run_seconds="$SECONDS"
|
# reset last_run_seconds if enough time has elapsed
|
||||||
|
last_run_seconds=0
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue