-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwatch.sh
More file actions
executable file
·32 lines (28 loc) · 814 Bytes
/
Copy pathwatch.sh
File metadata and controls
executable file
·32 lines (28 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env bash
# Poor-man's hot reload (no Xcode needed): on any Swift file save, rebuild and
# relaunch the app. ~3s per cycle. State resets each reload.
# Usage: ./watch.sh (Ctrl-C to stop)
set -uo pipefail
cd "$(dirname "$0")"
sig() { find Sources -name '*.swift' -exec stat -f '%m %N' {} + | sort; }
reload() {
if osascript - "$PWD/relaunch.sh" <<'APPLESCRIPT'
on run argv
do shell script quoted form of (item 1 of argv)
end run
APPLESCRIPT
then
echo "▸ app bundle rebuilt and relaunched $(date +%H:%M:%S)"
else
echo "✗ build failed — fix and save again (app left running)"
fi
}
trap 'exit 0' INT TERM
reload
last="$(sig)"
echo "▸ watching Sources/ … (Ctrl-C to stop)"
while true; do
sleep 1
now="$(sig)"
[ "$now" != "$last" ] && { last="$now"; reload; }
done