From f913eb978312c329974b5580af604e925c9e527c Mon Sep 17 00:00:00 2001 From: rcourtman Date: Tue, 28 Oct 2025 23:07:27 +0000 Subject: [PATCH] Fix hot-dev reload to detect new .go file creation The file watcher was only triggering on .go file modifications but missing new file creation. This happened because inotifywait sometimes reports the directory path first when a file is created. Changes: - Include event type in inotifywait output format - Trigger rebuild on CREATE/DELETE/MOVED events in addition to .go modifications - Add exclusions for temp files (.swp, .tmp, ~) Now creating new .go files will trigger an auto-rebuild. --- scripts/hot-dev.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/hot-dev.sh b/scripts/hot-dev.sh index 684c3d5..66d0e2f 100755 --- a/scripts/hot-dev.sh +++ b/scripts/hot-dev.sh @@ -229,13 +229,14 @@ printf "[hot-dev] Starting backend file watcher...\n" while true; do # Watch for changes to .go files (excluding vendor and node_modules) inotifywait -r -e modify,create,delete,move \ - --exclude '(vendor/|node_modules/|\.git/)' \ - --format '%w%f' \ + --exclude '(vendor/|node_modules/|\.git/|\.swp$|\.tmp$|~$)' \ + --format '%e %w%f' \ "${ROOT_DIR}/cmd" "${ROOT_DIR}/internal" "${ROOT_DIR}/pkg" 2>/dev/null | \ - while read -r changed_file; do - if [[ "$changed_file" == *.go ]]; then + while read -r event changed_file; do + # Rebuild on any .go file change OR any create/delete event (catches new files) + if [[ "$changed_file" == *.go ]] || [[ "$event" =~ CREATE|DELETE|MOVED ]]; then echo "" - echo "[hot-dev] 🔄 Go file changed: $(basename "$changed_file")" + echo "[hot-dev] 🔄 Change detected: $event $(basename "$changed_file")" echo "[hot-dev] Rebuilding backend..." # Rebuild the binary