ponk/scripts/development.sh

35 lines
698 B
Bash
Executable file

#!/bin/bash
if [ -z "$1" ]; then
echo "Pass the path to your game's resource pack directory as argument to this script!"
exit 1
fi
TARGET_PATH=$(realpath "$1")/ponk-dev
read -p "The directory \"$TARGET_PATH\" will be created or overwritten. Is this okay? [y/N] " -n 1 -r
if [[ "$REPLY" =~ ^[Yy]$ ]]; then
echo
else
exit 1
fi
DIRECTORY_TO_OBSERVE="pack"
function block_for_change {
inotifywait --recursive \
--event modify,move,create,delete \
$DIRECTORY_TO_OBSERVE
}
function build {
echo "Copying pack to $TARGET_PATH"
rm -rf "$TARGET_PATH"
sleep 1
cp -r "./pack" "$TARGET_PATH"
echo "Reload the game with F3+T now"
}
build
while block_for_change; do
build
done