Skip to content

Commit

Permalink
restore watch-and-repack to scripts dir
Browse files Browse the repository at this point in the history
  • Loading branch information
turbocrime committed Jul 3, 2024
1 parent 6f3ae4e commit 17a8cc3
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions scripts/watch-and-repack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

# Check if `PENUMBRA_ZONE_WEB_PATH` is set and points to a valid directory
if [ -z "$PENUMBRA_ZONE_WEB_PATH" ] || [ ! -d "$PENUMBRA_ZONE_WEB_PATH" ]; then
echo "Error: PENUMBRA_ZONE_WEB_PATH is not set or does not point to a valid directory."
exit 1
fi

# Check if `PRAX_REPO_PATH` is set and points to a valid directory
if [ -z "$PRAX_REPO_PATH" ] || [ ! -d "$PRAX_REPO_PATH" ]; then
echo "Error: PRAX_REPO_PATH is not set or does not point to a valid directory."
exit 1
fi

# Repack the packages in `penumbra-zone/web`
repack() {
(cd "$PENUMBRA_ZONE_WEB_PATH" && ./pack-public.sh)
}

# Install dependencies in `prax-wallet/web`
install_prax() {
(cd "$PRAX_REPO_PATH" && pnpm add -w $PENUMBRA_ZONE_WEB_PATH/packages/*/penumbra-zone-*-*.tgz)
}

# Reload webpack
reload_webpack() {
# Find the PID of the actively running webpack process
WEBPACK_PID=$(lsof -t -i:5175)

if [ -n "$WEBPACK_PID" ]; then
kill -9 $WEBPACK_PID
fi

(cd "$PRAX_REPO_PATH" && pnpm run dev &)
}

# Watch for changes in `penumbra-zone/web` and trigger repack and reload
while sleep 1; do
fswatch -1 -o "$PENUMBRA_ZONE_WEB_PATH/packages" | while read -r; do
repack
install_prax
reload_webpack
break
done
done

0 comments on commit 17a8cc3

Please sign in to comment.