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`
```bash
#!/usr/bin/env bash
dir="$(pwd)"
if [[ -n "$1" ]]; then
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
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
make "$@"
last_run_seconds="$SECONDS"
continue;
fi
make "$@"
last_run_seconds="$SECONDS"
if [[ $SECONDS -ge $((last_run_seconds + grace_seconds)) ]]; then
# reset last_run_seconds if enough time has elapsed
last_run_seconds=0
fi
done
```