2024-10-25 23:59:45 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2024-10-26 01:56:41 +00:00
|
|
|
# TODO: enumerate directories with shell
|
|
|
|
WATCH="db/ env/ fonts/ lib/ lightning/ pages/ public/ server/"
|
2024-12-11 07:18:43 +00:00
|
|
|
BINARY=magicwallet
|
2024-10-25 23:59:45 +00:00
|
|
|
PID=
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
function restart() {
|
|
|
|
date +%s.%N > public/__hotreload__
|
|
|
|
set +e
|
|
|
|
[[ -z "$PID" ]] || kill -15 $PID
|
|
|
|
make build -B
|
|
|
|
set -e
|
|
|
|
./$BINARY 2>&1 &
|
|
|
|
PID=$(pidof $BINARY)
|
|
|
|
}
|
|
|
|
|
|
|
|
function cleanup() {
|
|
|
|
rm -f public/__hotreload__
|
|
|
|
[[ -z "$PID" ]] || kill -15 $PID
|
|
|
|
}
|
|
|
|
trap cleanup EXIT
|
|
|
|
|
|
|
|
restart
|
2024-10-26 01:56:41 +00:00
|
|
|
while inotifywait -r -e modify $WATCH; do
|
|
|
|
echo
|
2024-10-25 23:59:45 +00:00
|
|
|
restart
|
|
|
|
done
|