Skip to content

Commit

Permalink
Merge pull request #163 from codacy/get-script-native
Browse files Browse the repository at this point in the history
feature: get.sh script get native version when on linux distro
  • Loading branch information
josemiguelmelo authored Mar 2, 2020
2 parents 35f2f41 + 7064372 commit 693b5be
Showing 1 changed file with 38 additions and 8 deletions.
46 changes: 38 additions & 8 deletions get.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,49 @@ if [ -z "$CODACY_REPORTER_VERSION" ]; then
CODACY_REPORTER_VERSION="latest"
fi

codacy_reporter="$codacy_temp_folder/codacy-coverage-reporter-assembly.jar"
download_coverage_reporter() {
if [ ! -f "$codacy_reporter" ]
then
log "$i" "Download the codacy reporter $1... ($CODACY_REPORTER_VERSION)"
curl -# -LS -o "$codacy_reporter" "$(curl -LSs https://api.github.com/repos/codacy/codacy-coverage-reporter/releases/$CODACY_REPORTER_VERSION | grep browser_download_url | grep $1 | cut -d '"' -f 4)"
else
log "$i" "Using codacy reporter $1 from cache"
fi
}

if [ ! -f "$codacy_reporter" ]
then
log "$i" "Download the codacy reporter... ($CODACY_REPORTER_VERSION)"
curl -LS -o "$codacy_reporter" "$(curl -LSs https://api.github.com/repos/codacy/codacy-coverage-reporter/releases/$CODACY_REPORTER_VERSION | grep browser_download_url | grep jar | cut -d '"' -f 4)"
run() {
eval $1
}

codacy_reporter_native_start_cmd() {
codacy_reporter="$codacy_temp_folder/codacy-coverage-reporter"
download_coverage_reporter "linux"
chmod +x $codacy_reporter
run_command="$codacy_reporter"
}

codacy_reporter_jar_start_cmd() {
codacy_reporter="$codacy_temp_folder/codacy-coverage-reporter-assembly.jar"
download_coverage_reporter "jar"
run_command="java -jar \"$codacy_reporter\""
}

run_command=""
unamestr=`uname`
if [ "$unamestr" = "Linux" ]; then
codacy_reporter_native_start_cmd
else
log "$i" "Using codacy reporter from cache"
codacy_reporter_jar_start_cmd
fi

if [ -z "$run_command" ]
then
fatal "Codacy coverage reporter command could not be found."
fi

if [ "$#" -gt 0 ];
then
java -jar "$codacy_reporter" $@
run "$run_command $@"
else
java -jar "$codacy_reporter" report
run "$run_command \"report\""
fi

0 comments on commit 693b5be

Please sign in to comment.