Skip to content

Commit

Permalink
Accept octet-stream for download
Browse files Browse the repository at this point in the history
  • Loading branch information
ysthakur committed Jul 15, 2023
1 parent c92d0bd commit 1affedb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
10 changes: 2 additions & 8 deletions bin/download
Original file line number Diff line number Diff line change
Expand Up @@ -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"
12 changes: 10 additions & 2 deletions lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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() {
Expand Down

0 comments on commit 1affedb

Please sign in to comment.