Skip to content

Commit 693b5be

Browse files
Merge pull request #163 from codacy/get-script-native
feature: get.sh script get native version when on linux distro
2 parents 35f2f41 + 7064372 commit 693b5be

File tree

1 file changed

+38
-8
lines changed

1 file changed

+38
-8
lines changed

get.sh

+38-8
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,49 @@ if [ -z "$CODACY_REPORTER_VERSION" ]; then
7373
CODACY_REPORTER_VERSION="latest"
7474
fi
7575

76-
codacy_reporter="$codacy_temp_folder/codacy-coverage-reporter-assembly.jar"
76+
download_coverage_reporter() {
77+
if [ ! -f "$codacy_reporter" ]
78+
then
79+
log "$i" "Download the codacy reporter $1... ($CODACY_REPORTER_VERSION)"
80+
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)"
81+
else
82+
log "$i" "Using codacy reporter $1 from cache"
83+
fi
84+
}
7785

78-
if [ ! -f "$codacy_reporter" ]
79-
then
80-
log "$i" "Download the codacy reporter... ($CODACY_REPORTER_VERSION)"
81-
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)"
86+
run() {
87+
eval $1
88+
}
89+
90+
codacy_reporter_native_start_cmd() {
91+
codacy_reporter="$codacy_temp_folder/codacy-coverage-reporter"
92+
download_coverage_reporter "linux"
93+
chmod +x $codacy_reporter
94+
run_command="$codacy_reporter"
95+
}
96+
97+
codacy_reporter_jar_start_cmd() {
98+
codacy_reporter="$codacy_temp_folder/codacy-coverage-reporter-assembly.jar"
99+
download_coverage_reporter "jar"
100+
run_command="java -jar \"$codacy_reporter\""
101+
}
102+
103+
run_command=""
104+
unamestr=`uname`
105+
if [ "$unamestr" = "Linux" ]; then
106+
codacy_reporter_native_start_cmd
82107
else
83-
log "$i" "Using codacy reporter from cache"
108+
codacy_reporter_jar_start_cmd
109+
fi
110+
111+
if [ -z "$run_command" ]
112+
then
113+
fatal "Codacy coverage reporter command could not be found."
84114
fi
85115

86116
if [ "$#" -gt 0 ];
87117
then
88-
java -jar "$codacy_reporter" $@
118+
run "$run_command $@"
89119
else
90-
java -jar "$codacy_reporter" report
120+
run "$run_command \"report\""
91121
fi

0 commit comments

Comments
 (0)