1
1
#! /usr/bin/env bash
2
- CC_WRAPPER_VERSION=" 0.0.13 "
2
+ CC_WRAPPER_VERSION=" 0.0.14 "
3
3
say () {
4
4
echo -e " $1 "
5
5
}
@@ -11,6 +11,21 @@ exit_if_error() {
11
11
exit 1;
12
12
fi
13
13
}
14
+ lower () {
15
+ echo $( echo $1 | sed ' s/CC//' | sed ' s/_/-//' | tr ' [:upper:]' ' [:lower:]' )
16
+ }
17
+ write_existing_args () {
18
+ if [ -n " $1 " ];
19
+ then
20
+ echo " --$( lower $1 ) $( eval echo \$ $1 ) "
21
+ fi
22
+ }
23
+ write_truthy_args () {
24
+ if [ " $1 " = " true" ];
25
+ then
26
+ echo " --$( lower $1 ) "
27
+ fi
28
+ }
14
29
b=" \033[0;36m" # variables/constants
15
30
g=" \033[0;32m" # info/debug
16
31
r=" \033[0;31m" # errors
@@ -25,7 +40,6 @@ say " _____ _
25
40
"
26
41
CC_VERSION=" ${CC_VERSION:- latest} "
27
42
CC_FAIL_ON_ERROR=" ${CC_FAIL_ON_ERROR:- false} "
28
- say
29
43
if [ -n " $CC_BINARY " ];
30
44
then
31
45
if [ -f " $CC_BINARY " ];
@@ -90,113 +104,41 @@ CC_PUBLIC_PGP_KEY=$(curl https://keybase.io/codecovsecurity/pgp_keys.asc)
90
104
say
91
105
fi
92
106
cc_cli_args=()
93
- if [ -n " $CC_AUTO_LOAD_PARAMS_FROM " ];
94
- then
95
- cc_cli_args+=( " --auto-load-params-from " " ${CC_AUTO_LOAD_PARAMS_FROM} " )
96
- fi
97
- if [ -n " $CC_ENTERPRISE_URL " ];
98
- then
99
- cc_cli_args+=( " --enterprise-url " " ${CC_ENTERPRISE_URL} " )
100
- fi
101
- unset CC_YML_PATH
102
- if [ -n " $CC_YML_PATH " ];
103
- then
104
- cc_cli_args+=( " --codecov-yml-path " " ${CC_YML_PATH} " )
105
- fi
107
+ cc_cli_args+=( $( write_existing_args CC_AUTO_LOAD_PARAMS_FROM) )
108
+ cc_cli_args+=( $( write_existing_args CC_ENTERPRISE_URL) )
109
+ cc_cli_args+=( $( write_existing_args CC_YML_PATH) )
106
110
cc_cc_args=()
107
- if [ " $CC_FAIL_ON_ERROR " = " true" ];
108
- then
109
- cc_cc_args+=( " --fail-on-error" )
110
- fi
111
- if [ -n " $CC_GIT_SERVICE " ];
112
- then
113
- cc_cc_args+=( " --git-service " " ${CC_GIT_SERVICE} " )
114
- fi
115
- if [ -n " $CC_PARENT_SHA " ];
116
- then
117
- cc_cc_args+=( " --parent-sha " " ${CC_PARENT_SHA} " )
118
- fi
119
- if [ -n " $CC_PULL_REQUEST " ];
120
- then
121
- cc_cc_args+=( " --pr " " ${CC_PULL_REQUEST} " )
122
- fi
123
- if [ -n " $CC_SHA " ];
124
- then
125
- cc_cc_args+=( " --sha " " ${CC_SHA} " )
126
- fi
127
- if [ -n " $CC_SLUG " ];
128
- then
129
- cc_cc_args+=( " --slug " " ${CC_SLUG} " )
130
- fi
111
+ cc_cc_args+=( $( write_truthy_args CC_FAIL_ON_ERROR) )
112
+ cc_cc_args+=( $( write_existing_args CC_GIT_SERVICE) )
113
+ cc_cc_args+=( $( write_existing_args CC_PARENT_SHA) )
114
+ cc_cc_args+=( $( write_existing_args CC_PR) )
115
+ cc_cc_args+=( $( write_existing_args CC_SHA) )
116
+ cc_cc_args+=( $( write_existing_args CC_SLUG) )
131
117
cc_create_report_args=()
132
- if [ -n " $CC_CODE " ];
133
- then
134
- cc_cr_args+=( " --code " " ${CC_CODE} " )
135
- fi
136
- if [ " $CC_FAIL_ON_ERROR " = " true" ];
137
- then
138
- cc_cr_args+=( " --fail-on-error" )
139
- fi
140
- if [ -n " $CC_GIT_SERVICE " ];
141
- then
142
- cc_cr_args+=( " --git-service " " ${CC_GIT_SERVICE} " )
143
- fi
144
- if [ -n " $CC_PULL_REQUEST " ];
145
- then
146
- cc_cr_args+=( " --pr " " ${CC_PULL_REQUEST} " )
147
- fi
148
- if [ -n " $CC_SHA " ];
149
- then
150
- cc_cr_args+=( " --sha " " ${CC_SHA} " )
151
- fi
152
- if [ -n " $CC_SLUG " ];
153
- then
154
- cc_cr_args+=( " --slug " " ${CC_SLUG} " )
155
- fi
118
+ cc_cr_args+=( $( write_existing_args CC_CODE) )
119
+ cc_cr_args+=( $( write_truthy_args CC_FAIL_ON_ERROR) )
120
+ cc_cr_args+=( $( write_existing_args CC_GIT_SERVICE) )
121
+ cc_cr_args+=( $( write_existing_args CC_PR) )
122
+ cc_cr_args+=( $( write_existing_args CC_SHA) )
123
+ cc_cr_args+=( $( write_existing_args CC_SLUG) )
156
124
cc_du_args=()
157
125
OLDIFS=$IFS ; IFS=,
158
- if [ -n " $CC_BRANCH " ];
159
- then
160
- cc_du_args+=( " --branch " " ${CC_BRANCH} " )
161
- fi
162
- if [ -n " $CC_BUILD " ];
163
- then
164
- cc_du_args+=( " --build " " ${CC_BUILD} " )
165
- fi
166
- if [ -n " $CC_BUILD_URL " ];
167
- then
168
- cc_du_args+=( " --build-url " " ${CC_BUILD_URL} " )
169
- fi
170
- if [ -n " $CC_CODE " ];
171
- then
172
- cc_du_args+=( " --code " " ${CC_CODE} " )
173
- fi
174
- if [ " $CC_DISABLE_FILE_FIXES " = " true" ];
175
- then
176
- cc_du_args+=( " --disable-file-fixes" )
177
- fi
178
- if [ " $CC_DISABLE_SEARCH " = " true" ];
179
- then
180
- cc_du_args+=( " --disable-search" )
181
- fi
182
- if [ " $CC_DRY_RUN " = " true" ];
183
- then
184
- cc_du_args+=( " --dry-run" )
185
- fi
186
- if [ -n " $CC_ENV " ];
187
- then
188
- cc_du_args+=( " --env " " ${CC_ENV} " )
189
- fi
190
- if [ -n " $CC_EXCLUDE_DIRS " ];
191
- then
192
- for directory in $CC_EXCLUDE_DIRS ; do
126
+ cc_du_args+=( $( write_existing_args CC_BRANCH) )
127
+ cc_du_args+=( $( write_existing_args CC_BUILD) )
128
+ cc_du_args+=( $( write_existing_args CC_BUILD_URL) )
129
+ cc_du_args+=( $( write_existing_args CC_CODE) )
130
+ cc_du_args+=( $( write_existing_args CC_DIR) )
131
+ cc_du_args+=( $( write_truthy_args CC_DISABLE_FILE_FIXES) )
132
+ cc_du_args+=( $( write_truthy_args CC_DISABLE_SEARCH) )
133
+ cc_du_args+=( $( write_truthy_args CC_DRY_RUN) )
134
+ cc_du_args+=( $( write_existing_args CC_ENV) )
135
+ if [ -n " $CC_EXCLUDES " ];
136
+ then
137
+ for directory in $CC_EXCLUDES ; do
193
138
cc_du_args+=( " --exclude " " $directory " )
194
139
done
195
140
fi
196
- if [ " $CC_FAIL_ON_ERROR " = " true" ];
197
- then
198
- cc_du_args+=( " --fail-on-error" )
199
- fi
141
+ cc_du_args+=( $( write_truthy_args CC_FAIL_ON_ERROR) )
200
142
if [ -n " $CC_FILES " ];
201
143
then
202
144
for file in $CC_FILES ; do
@@ -209,64 +151,24 @@ then
209
151
cc_du_args+=( " --flag " " $flag " )
210
152
done
211
153
fi
212
- if [ -n " $CC_GIT_SERVICE " ];
213
- then
214
- cc_du_args+=( " --git-service " " ${CC_GIT_SERVICE} " )
215
- fi
216
- if [ " $CC_HANDLE_NO_REPORTS_FOUND " = " true" ];
217
- then
218
- cc_du_args+=( " --handle-no-reports-found" )
219
- fi
220
- if [ -n " $CC_JOB_CODE " ];
221
- then
222
- cc_du_args+=( " --job-code " " ${CC_JOB_CODE} " )
223
- fi
224
- if [ " $CC_LEGACY " = " true" ];
225
- then
226
- cc_du_args+=( " --legacy" )
227
- fi
228
- if [ -n " $CC_NAME " ];
229
- then
230
- cc_du_args+=( " --name " " ${CC_NAME} " )
231
- fi
232
- if [ -n " $CC_NETWORK_FILTER " ];
233
- then
234
- cc_du_args+=( " --network-filter " " ${CC_NETWORK_FILTER} " )
235
- fi
236
- if [ -n " $CC_NETWORK_PREFIX " ];
237
- then
238
- cc_du_args+=( " --network-prefix " " ${CC_NETWORK_PREFIX} " )
239
- fi
240
- if [ -n " $CC_NETWORK_ROOT_FOLDER " ];
241
- then
242
- cc_du_args+=( " --network-root-folder " " ${CC_NETWORK_ROOT_FOLDER} " )
243
- fi
154
+ cc_du_args+=( $( write_existing_args CC_GIT_SERVICE) )
155
+ cc_du_args+=( $( write_truthy_args CC_HANDLE_NO_REPORTS_FOUND) )
156
+ cc_du_args+=( $( write_existing_args CC_JOB_CODE) )
157
+ cc_du_args+=( $( write_truthy_args CC_LEGACY) )
158
+ cc_du_args+=( $( write_existing_args CC_NAME) )
159
+ cc_du_args+=( $( write_existing_args CC_NETWORK_FILTER) )
160
+ cc_du_args+=( $( write_existing_args CC_NETWORK_PREFIX) )
161
+ cc_du_args+=( $( write_existing_args CC_NETWORK_ROOT_FOLDER) )
244
162
if [ -n " $CC_PLUGINS " ];
245
163
then
246
164
for plugin in $CC_PLUGINS ; do
247
165
cc_du_args+=( " --plugin " " $plugin " )
248
166
done
249
167
fi
250
- if [ -n " $CC_PULL_REQUEST " ];
251
- then
252
- cc_du_args+=( " --pr " " ${CC_PULL_REQUEST} " )
253
- fi
254
- if [ -n " $CC_REPORT_TYPE " ];
255
- then
256
- cc_du_args+=( " --report-type " " ${CC_REPORT_TYPE} " )
257
- fi
258
- if [ -n " $CC_SEARCH_DIR " ];
259
- then
260
- cc_du_args+=( " --coverage-files-search-root-folder " " ${CC_SEARCH_DIR} " )
261
- fi
262
- if [ -n " $CC_SHA " ];
263
- then
264
- cc_du_args+=( " --sha " " ${CC_SHA} " )
265
- fi
266
- if [ -n " $CC_SLUG " ];
267
- then
268
- cc_du_args+=( " --slug " " ${CC_SLUG} " )
269
- fi
168
+ cc_du_args+=( $( write_existing_args CC_PR) )
169
+ cc_du_args+=( $( write_existing_args CC_REPORT_TYPE) )
170
+ cc_du_args+=( $( write_existing_args CC_SHA) )
171
+ cc_du_args+=( $( write_existing_args CC_SLUG) )
270
172
IFS=$OLDIFS
271
173
unset NODE_OPTIONS
272
174
# See https://github.com/codecov/uploader/issues/475
0 commit comments