Files
ghostMode/scripts/watch.sh
T
exteraGramPlugins 7a3d3e505d Initial commit
2026-10-09 12:23:57 +00:00

40 lines
908 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")/.."
source scripts/lib.sh
need_cmd "$PY"
checksum() {
find src plugin.json -type f -printf '%T@ %p\n' 2>/dev/null | sha256sum
}
run_deploy() {
if ! scripts/deploy.sh "$@"; then
echo "deploy failed, still watching..." >&2
fi
}
echo "watching src/ and plugin.json for changes..."
run_deploy "$@"
if command -v inotifywait >/dev/null 2>&1; then
while true; do
inotifywait -qq -r -e close_write,create,delete,move src plugin.json 2>/dev/null || true
sleep 0.3
run_deploy "$@"
done
else
echo "inotifywait not found; falling back to polling" >&2
last="$(checksum)"
while true; do
sleep 1
current="$(checksum)"
if [[ "$current" != "$last" ]]; then
last="$current"
sleep 0.3
run_deploy "$@"
fi
done
fi