Skip to content

Commit

Permalink
add support for asdf latest bun
Browse files Browse the repository at this point in the history
  • Loading branch information
cometkim committed Nov 1, 2024
1 parent aeb1a82 commit 48556e3
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions bin/latest-stable
Original file line number Diff line number Diff line change
@@ -0,0 1,26 @@
#!/usr/bin/env bash

set -eo pipefail

current_script_path=${BASH_SOURCE[0]}
plugin_dir=$(dirname "$(dirname "$current_script_path")")

# shellcheck source=lib/utils.bash
source "${plugin_dir}/lib/utils.bash"

curl_opts=(-sI)

if [ -n "${GITHUB_API_TOKEN:-}" ]; then
curl_opts=("${curl_opts[@]}" -H "Authorization: token $GITHUB_API_TOKEN")
fi

redirect_url=$(curl "${curl_opts[@]}" "$REPO_URL/releases/latest" | sed -n -e "s|^location: *||p" | sed -n -e "s|\r||p")
version=
printf "redirect url: %s\n" "$redirect_url" >&2
if [[ "$redirect_url" == "$REPO_URL/releases" ]]; then
version="$(list_github_releases | sort_versions | tail -n1 | xargs echo)"
else
version="$(printf "%s\n" "$redirect_url" | sed 's|.*/tag/bun-v||')"
fi

printf "%s\n" "$version"

0 comments on commit 48556e3

Please sign in to comment.