Skip to content

Commit

Permalink
build-all.sh: Add error handling in cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
stefandesu committed Jan 16, 2024
1 parent a9e531a commit dd107a4
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions build/build-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,15 @@ git stash push -u -m before-build-all
# Save current Node version to reset after building all the versions
FNM_VERSION="$(fnm current)"

# shellcheck disable=SC2317
function cleanup {
echo
echo "==================== Cleaning up ===================="
if [ "$1" != "0" ]; then
echo "Note: Error $1 occurred on line $2"
echo
fi

git reset --hard
git checkout dev

Expand All @@ -51,10 +57,12 @@ function cleanup {

rm -r temp

# TODO: Maybe we can disambiguate between success and failure states somehow
if [ "$1" != "0" ]; then
exit 1
fi
exit 0
}
trap cleanup EXIT
trap 'cleanup $? $LINENO' EXIT

rm -rf releases
mkdir releases
Expand Down Expand Up @@ -102,3 +110,5 @@ done

# Create symlink for "master" if exists
test -e releases/master && ln -s master releases/app

exit 0

0 comments on commit dd107a4

Please sign in to comment.