diff --git a/bin/download b/bin/download index b104db2..da7675d 100755 --- a/bin/download +++ b/bin/download @@ -11,13 +11,7 @@ source "${plugin_dir}/lib/utils.bash" mkdir -p "$ASDF_DOWNLOAD_PATH" # TODO: Adapt this to proper extension and adapt extracting strategy. -release_file="$ASDF_DOWNLOAD_PATH/$TOOL_NAME-$ASDF_INSTALL_VERSION.tar.gz" +release_file="$ASDF_DOWNLOAD_PATH/$TOOL_NAME-$ASDF_INSTALL_VERSION" -# Download tar.gz file to the download directory +# Download executable to the download directory download_release "$ASDF_INSTALL_VERSION" "$release_file" - -# Extract contents of tar.gz file into the download directory -tar -xzf "$release_file" -C "$ASDF_DOWNLOAD_PATH" --strip-components=1 || fail "Could not extract $release_file" - -# Remove the tar.gz file since we don't need to keep it -rm "$release_file" diff --git a/lib/utils.bash b/lib/utils.bash index 1ea3710..c3f9af2 100644 --- a/lib/utils.bash +++ b/lib/utils.bash @@ -53,10 +53,15 @@ list_github_tags() { gh_query "releases" | tag_names } +get_release_id() { + local tag="$1" + $(gh_query "releases/tags/$tag" | get_num_value_from_json "id" | head -n 1) +} + # Given a tag, list its scala-ammonite versions list_assets() { local tag="$1" - local id=$(gh_query "releases/tags/$tag" | get_num_value_from_json "id" | head -n 1) + local id=$(get_release_id "$tag") gh_query "releases/$id/assets" | get_str_value_from_json "name" | cut -d '-' -f 1,2 | uniq } @@ -81,7 +86,10 @@ download_release() { local url="$GH_REPO/releases/download/$tag/$version" echo "* Downloading $TOOL_NAME release $version..." - curl "${curl_opts[@]}" -o "$filename" -C - "$url" || fail "Could not download $url" + curl "${curl_opts[@]}" \ + -H "Accept: application/octet-stream" \ + -o "$filename" -C - "$url" || + fail "Could not curl $url_rest" } install_version() {