Add basic error handling to the export-pack script

This commit is contained in:
Sergeant Acoustic 2026-06-17 20:00:03 +01:00
parent c8988595bd
commit ea816a5600

View file

@ -40,11 +40,21 @@ echo "# Cloning/updating MC Rebalance mod"
git clone --single-branch --branch 1.21 "https://patience.nearmisses.xyz/patience/mc_rebalance.git" "${basedir}/deps/mc_rebalance" 2> /dev/null || \ git clone --single-branch --branch 1.21 "https://patience.nearmisses.xyz/patience/mc_rebalance.git" "${basedir}/deps/mc_rebalance" 2> /dev/null || \
(cd "${basedir}/deps/mc_rebalance"; git pull > /dev/null) (cd "${basedir}/deps/mc_rebalance"; git pull > /dev/null)
if [ $? -ne 0 ]; then
echo "Error during mod clone/update, do you have internet?"
exit 1
fi
# Compile the mod # Compile the mod
echo "# Compiling MC Rebalance mod" echo "# Compiling MC Rebalance mod"
rm -f "${basedir}/deps/mc_rebalance/build/libs/mc_rebalance-"*".jar" rm -f "${basedir}/deps/mc_rebalance/build/libs/mc_rebalance-"*".jar"
(cd "${basedir}/deps/mc_rebalance/" && ./gradlew build > /dev/null) (cd "${basedir}/deps/mc_rebalance/" && ./gradlew build > /dev/null)
if [ $? -ne 0 ]; then
echo "Error during mod compilation"
exit 1
fi
# Clean up old mod files # Clean up old mod files
rm -f "${basedir}/overrides/mods/mc_rebalance-"*".jar" rm -f "${basedir}/overrides/mods/mc_rebalance-"*".jar"
cp "$(find "${basedir}/deps/mc_rebalance/build/libs" -regex "${basedir}/deps\/mc_rebalance\/build\/libs\/mc_rebalance-[0-9\.]+\.jar")" "${basedir}/overrides/mods" cp "$(find "${basedir}/deps/mc_rebalance/build/libs" -regex "${basedir}/deps\/mc_rebalance\/build\/libs\/mc_rebalance-[0-9\.]+\.jar")" "${basedir}/overrides/mods"
@ -90,4 +100,5 @@ if [ $? -eq 0 ]; then
echo "Successfully exported the client modpack to ${basedir}/release/MC_Rebalance_${version}.mrpack" echo "Successfully exported the client modpack to ${basedir}/release/MC_Rebalance_${version}.mrpack"
else else
echo "An unknown error occured while zipping the pack" echo "An unknown error occured while zipping the pack"
exit 1
fi fi