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.
This commit is contained in:
parent
99b11760ac
commit
f913eb9783
1 changed files with 6 additions and 5 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue