Skip to content

Commit

Permalink
Calculate the resulting_hash beforehand
Browse files Browse the repository at this point in the history
  • Loading branch information
dirtyhabits97 committed Sep 15, 2021
1 parent 08c24ee commit 869a152
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions ext/swiftlint/downloadSwiftlint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,19 @@ done

set -x

### Download
mkdir -p "${destination}"
curl -s -L "${url}" -o "${asset}"

# If macOS
if [[ "$OSTYPE" == "darwin"* ]]; then
hash_cmd="md5 -q ${asset}"
resulting_hash=`md5 -q ${asset}`
# Default to linux
else
hash_cmd="md5sum ${asset} | awk '{ print $1 }'"
resulting_hash=`md5sum ${asset} | awk '{ print $1 }'`
fi

### Download
mkdir -p "${destination}"
curl -s -L "${url}" -o "${asset}"
if [[ ! -z "${SWIFTLINT_VERSION}" || "$hash_cmd" == "${default_hash}" ]]; then
if [[ ! -z "${SWIFTLINT_VERSION}" || "$resulting_hash" == "${default_hash}" ]]; then
# if another version is set || our hardcoded hash is correct
unzip -o -q "${asset}" -d "${destination}"
else
Expand Down

0 comments on commit 869a152

Please sign in to comment.