style changes
All checks were successful
/ build (push) Successful in 5s

This commit is contained in:
Collin Lefeber 2025-02-16 21:18:49 -05:00
parent 165e4ed60d
commit 70a1bb05d3

View file

@ -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
``` ```