-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
restore watch-and-repack to scripts dir
- Loading branch information
1 parent
6f3ae4e
commit 17a8cc3
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |