improvement(builder): make regex more specific

So it matches `.git` but not `..git..`.

Also makes a few other tweaks:

- ignore 4913 from watching: vim creates this sometimes
- improve inotifywait command
This commit is contained in:
Ankur Sinha (Ankur Sinha Gmail) 2022-09-26 11:25:18 +01:00
parent 1d0180893a
commit ee0430be61
No known key found for this signature in database
GPG key ID: F8D8C0BEBAC898BD

View file

@ -7,7 +7,12 @@ cmd="--html-url-extension-style=indexify site.yml"
srcdir="modules"
buildir="public"
previewpidfile="preview.pid"
inotifyignore=".git*"
# 4913: for vim users, vim creates a temporary file to test it can write to
# directory
# https://groups.google.com/g/vim_dev/c/sppdpElxY44
# .git: so we don't get rebuilds each time git metadata changes
inotifyignore="\.git.*|4913"
watch_and_build () {
if ! command -v inotifywait > /dev/null
@ -29,12 +34,12 @@ watch_and_build () {
# temporary files that are updated regularly and so on, so better
# to get the list from git. It'll also look at global gitingore
# settings and so on.
inotifyignore="$(git status -s --ignored | grep '^!!' | sed -e 's/^!! //' -e 's:/:\*:' | tr '\n' '|')${inotifyignore}"
inotifyignore="$(git status -s --ignored | grep '^!!' | sed -e 's/^!! //' | tr '\n' '|')${inotifyignore}"
fi
while true
do
echo "Watching current directory (excluding ${inotifyignore}) for changes and re-building as required. Use Ctrl C to stop."
echo "Watching current directory (excluding: ${inotifyignore}) for changes and re-building as required. Use Ctrl C to stop."
inotifywait -q --exclude "($inotifyignore)" -e modify,create,delete,move -r . && echo "Change detected, rebuilding.." && build
done
fi