From e8de4b7e8e35df5d3e6a27861a386b1a8bd146b1 Mon Sep 17 00:00:00 2001 From: Serge Guzik Date: Mon, 18 Feb 2019 16:36:46 +0200 Subject: [PATCH] refactor: Add more potential error handling --- warp4j | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/warp4j b/warp4j index 6c2491b..c7f0528 100755 --- a/warp4j +++ b/warp4j @@ -669,8 +669,17 @@ function warp_targets() { --exec "$LAUNCHER_NAME.sh" \ --output "$WARPED_TEMP_PATH/$LIN/$APP_NAME" \ &> /dev/null + if [[ $? != 0 ]]; then + echo "Error: Failed to warp for $LIN" >&2 + fail + fi + echo "Archiving for $LIN..." tar -C "$WARPED_TEMP_PATH/$LIN" -czf "$WARPED_TEMP_PATH/$APP_NAME-$LIN-x64.tar.gz" "$APP_NAME" - mv "$WARPED_TEMP_PATH/$LIN/$APP_NAME" "$WARPED_PATH/$APP_NAME-$LIN" + if [[ $? != 0 ]]; then + echo "Error: Failed to make archive for $LIN" >&2 + fail + fi + mv "$WARPED_TEMP_PATH/$LIN/$APP_NAME" "$WARPED_PATH/$APP_NAME-$LIN-x64" mv "$WARPED_TEMP_PATH/$APP_NAME-$LIN-x64.tar.gz" "$WARPED_PATH" rmdir "$WARPED_TEMP_PATH/$LIN" fi @@ -684,8 +693,17 @@ function warp_targets() { --exec "$LAUNCHER_NAME.sh" \ --output "$WARPED_TEMP_PATH/$MAC/$APP_NAME" \ &> /dev/null + if [[ $? != 0 ]]; then + echo "Error: Failed to warp for $MAC" >&2 + fail + fi + echo "Archiving for $MAC..." tar -C "$WARPED_TEMP_PATH/$MAC" -czf "$WARPED_TEMP_PATH/$APP_NAME-$MAC-x64.tar.gz" "$APP_NAME" - mv "$WARPED_TEMP_PATH/$MAC/$APP_NAME" "$WARPED_PATH/$APP_NAME-$MAC" + if [[ $? != 0 ]]; then + echo "Error: Failed to make archive for $MAC" >&2 + fail + fi + mv "$WARPED_TEMP_PATH/$MAC/$APP_NAME" "$WARPED_PATH/$APP_NAME-$MAC-x64" mv "$WARPED_TEMP_PATH/$APP_NAME-$MAC-x64.tar.gz" "$WARPED_PATH" rmdir "$WARPED_TEMP_PATH/$MAC" fi @@ -699,14 +717,23 @@ function warp_targets() { --exec "$LAUNCHER_NAME.cmd" \ --output "$WARPED_TEMP_PATH/$WIN/$APP_NAME.exe" \ &> /dev/null + if [[ $? != 0 ]]; then + echo "Error: Failed to warp for $WIN" >&2 + fail + fi if command -v zip &> /dev/null ; then ( + echo "Archiving for $WIN..." cd "$WARPED_TEMP_PATH/$WIN" zip -r "$WARPED_TEMP_PATH/$APP_NAME-$WIN-x64.zip" "$APP_NAME.exe" &> /dev/null + if [[ $? != 0 ]]; then + echo "Error: Failed to make archive for $WIN" >&2 + fail + fi mv "$WARPED_TEMP_PATH/$APP_NAME-$WIN-x64.zip" "$WARPED_PATH" ) else echo "Warning: 'zip' not found, will skip creation of archive for windows" >&2 fi - mv "$WARPED_TEMP_PATH/$WIN/$APP_NAME.exe" "$WARPED_PATH/$APP_NAME-windows.exe" + mv "$WARPED_TEMP_PATH/$WIN/$APP_NAME.exe" "$WARPED_PATH/$APP_NAME-windows-x64.exe" rmdir "$WARPED_TEMP_PATH/$WIN" fi