forked from ashfurrow/danger-ruby-swiftlint
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove environment variables and use parameters instead (ashfurrow#162)
- Loading branch information
1 parent
0526364
commit 14b0721
Showing
2 changed files
with
43 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,43 @@ | ||
#!/usr/bin/env bash | ||
# frozen_string_literal: true | ||
|
||
mkdir -p "${DESTINATION}" | ||
curl -s -L "${URL}" -o "${ASSET}" | ||
if [[ $(md5 -q "${ASSET}") != "${SWIFTLINT_MD5_HASH}" ]]; then | ||
echo "Zip was corrupted, try again later." | ||
### Load arguments | ||
while [[ $# > 0 ]] | ||
do | ||
case "$1" in | ||
-u|--url) | ||
url="$2" | ||
shift;; | ||
|
||
-d|--destination) | ||
destination="$2" | ||
shift;; | ||
|
||
-a|--asset) | ||
asset="$2" | ||
shift;; | ||
|
||
-dh|--default_hash) | ||
default_hash="$2" | ||
shift;; | ||
|
||
--help|*) | ||
echo "Usage:" | ||
echo ' -u --url: URL for SwiftLint version to download' | ||
echo ' -d --destination: Folder where SwiftLint will be downloaded' | ||
echo " -a --asset: Temporary name for the zip file" | ||
echo " -dh --default_hash: Default SwiftLint md5 hash to check for if no version specified" | ||
exit 1;; | ||
esac | ||
shift | ||
done | ||
|
||
### Download | ||
mkdir -p "${destination}" | ||
curl -s -L "${url}" -o "${asset}" | ||
if [[ ! -z "${SWIFTLINT_VERSION}" || $(md5 -q "${asset}") == "${default_hash}" ]]; then | ||
# if another version is set || our hardcoded hash is correct | ||
unzip -o -q "${asset}" -d "${destination}" | ||
else | ||
unzip -o -q "${ASSET}" -d "${DESTINATION}" | ||
echo "Zip was corrupted, try again later." | ||
fi | ||
rm "${ASSET}" | ||
rm "${asset}" |