From ee0430be61ac6fd866bb3b322fcc407895106c21 Mon Sep 17 00:00:00 2001 From: Ankur Sinha (Ankur Sinha Gmail) Date: Sep 26 2022 10:25:18 +0000 Subject: 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 --- diff --git a/builder.sh b/builder.sh index bb0e746..a4ed8dd 100755 --- a/builder.sh +++ b/builder.sh @@ -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