diff --git a/ext/swiftlint/Rakefile b/ext/swiftlint/Rakefile index 779ed33..1dd85c0 100644 --- a/ext/swiftlint/Rakefile +++ b/ext/swiftlint/Rakefile @@ -16,7 +16,7 @@ namespace :swiftlint do SWIFTLINT_MD5_HASH = DangerSwiftlint::SWIFTLINT_HASH puts "Downloading swiftlint@#{VERSION}" - sh "sh #{SCRIPT_PATH}/downloadSwiftlint.sh -u #{URL} -d #{DESTINATION} -a #{ASSET} -dh #{SWIFTLINT_MD5_HASH}" + sh "#{SCRIPT_PATH}/downloadSwiftlint.sh -u #{URL} -d #{DESTINATION} -a #{ASSET} -dh #{SWIFTLINT_MD5_HASH}" end end diff --git a/ext/swiftlint/downloadSwiftlint.sh b/ext/swiftlint/downloadSwiftlint.sh index 1d6323d..19b29c1 100755 --- a/ext/swiftlint/downloadSwiftlint.sh +++ b/ext/swiftlint/downloadSwiftlint.sh @@ -34,7 +34,16 @@ done ### Download mkdir -p "${destination}" curl -s -L "${url}" -o "${asset}" -if [[ ! -z "${SWIFTLINT_VERSION}" || $(md5 -q "${asset}") == "${default_hash}" ]]; then + +# If macOS +if [[ "$OSTYPE" == "darwin"* ]]; then + resulting_hash=`md5 -q ${asset}` +# Default to linux +else + resulting_hash=`md5sum ${asset} | awk '{ print $1 }'` +fi + +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 diff --git a/spec/danger_plugin_spec.rb b/spec/danger_plugin_spec.rb index af8927c..75ad33b 100755 --- a/spec/danger_plugin_spec.rb +++ b/spec/danger_plugin_spec.rb @@ -220,6 +220,7 @@ module Danger end it 'crashes if renamed_files is not configured properly' do + allow_any_instance_of(Swiftlint).to receive(:lint).and_return('') allow(@swiftlint.git).to receive(:modified_files).and_return([ 'spec/fixtures/SwiftFileThatWasRenamedToSomethingElse.swift' ]) @@ -227,6 +228,7 @@ module Danger end it 'does not crash if a modified file was renamed' do + allow_any_instance_of(Swiftlint).to receive(:lint).and_return('') allow(@swiftlint.git).to receive(:modified_files).and_return([ 'spec/fixtures/SwiftFileThatWasRenamedToSomethingElse.swift' ])