Skip to content

Commit

Permalink
Merge pull request #172 from codacy/use-wget-or-curl
Browse files Browse the repository at this point in the history
feature: Use wget when available otherwise curl
  • Loading branch information
josemiguelmelo authored Mar 9, 2020
2 parents 59ffacf + eea3d9c commit 588d34a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ Or use the flag: `--codacy-api-base-url <Codacy_instance_URL>:16006`.

## Running Codacy Coverage Reporter

Requirements: bash, curl, glibc.
Requirements:

- bash
- curl or wget
- glibc

```bash
bash <(curl -Ls https://coverage.codacy.com/get.sh)
Expand Down
17 changes: 16 additions & 1 deletion get.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,26 @@ if [ -z "$CODACY_REPORTER_VERSION" ]; then
CODACY_REPORTER_VERSION="latest"
fi

download_url() {
grep browser_download_url | grep $1 | cut -d '"' -f 4
}

download_using_wget_or_curl() {
api_url="https://api.github.com/repos/codacy/codacy-coverage-reporter/releases/$CODACY_REPORTER_VERSION"
if [ -x "$(which curl)" ]; then
curl -# -LS -o "$codacy_reporter" "$(curl -LSs $api_url | download_url $1)"
elif [ -x "$(which wget)" ] ; then
wget -O "$codacy_reporter" "$(wget -O - $api_url | download_url $1)"
else
fatal "Could not find curl or wget, please install one."
fi
}

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)"
download_using_wget_or_curl $1
else
log "$i" "Using codacy reporter $1 from cache"
fi
Expand Down

0 comments on commit 588d34a

Please sign in to comment.