Skip to content

Commit

Permalink
use grep/sed instead of jq for list-all
Browse files Browse the repository at this point in the history
  • Loading branch information
klundberg committed Aug 27, 2019
1 parent c6d09a4 commit 647281a
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions bin/list-all
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,12 @@

set -eo pipefail

# shellcheck source=../lib/utils.sh
source "$(dirname "$0")/../lib/utils.sh"

RELEASES_URL="https://api.github.com/repos/realm/swiftlint/releases"

curl_github() {
if [ -n "$GITHUB_API_TOKEN" ]; then
curl -s -H "Authorization: token $GITHUB_API_TOKEN" "$@"
else
curl -s "$@"
fi
}

download_jq_if_needed

# fetch releases api endpoint, filter tag names thru jq,
# reverse sort, then replace newlines with spaces
curl_github $RELEASES_URL \
| $(jq_path) --raw-output '.[].tag_name' \
| tac \
| tr '\n' ' '
curl_cmd="curl -s"
if [ -n "$GITHUB_API_TOKEN" ]; then
curl_cmd="$curl_cmd -H \"Authorization: token $GITHUB_API_TOKEN\""
fi
curl_cmd="$curl_cmd $RELEASES_URL"

# | tee /dev/tty \
echo $(eval "$curl_cmd" | grep tag_name | sed 's/"tag_name": //g;s/"//g;s/,//g' | (tac 2>/dev/null || tail -r) | xargs)

0 comments on commit 647281a

Please sign in to comment.