@@ -73,19 +73,49 @@ if [ -z "$CODACY_REPORTER_VERSION" ]; then
73
73
CODACY_REPORTER_VERSION=" latest"
74
74
fi
75
75
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
+ }
77
85
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
82
107
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."
84
114
fi
85
115
86
116
if [ " $# " -gt 0 ];
87
117
then
88
- java -jar " $codacy_reporter " $@
118
+ run " $run_command $@ "
89
119
else
90
- java -jar " $codacy_reporter " report
120
+ run " $run_command \" report\" "
91
121
fi
0 commit comments