diff --git a/bin/download b/bin/download index 9d289e0..a0dd36b 100755 --- a/bin/download +++ b/bin/download @@ -12,14 +12,11 @@ function download_version() { local version=$1 local download_path=$2 - local platform - platform=$(get_platform) - - local arch - arch=$(get_arch) + local bin_target + bin_target=$(get_bin_target) local bin_url - bin_url=$(get_bin_url "$version" "$platform" "$arch") + bin_url=$(get_bin_url "$version" "$bin_target") local tmpdir tmpdir=$(get_temp_dir) @@ -31,7 +28,7 @@ function download_version() { echo "Downloading Bun v$version..." curl "${curl_opts[@]}" -o "$tmpdir/bun.zip" "$bin_url" || fail "Couldn't download the Bun binary from $bin_url" - unzip -j "$tmpdir/bun.zip" "bun-$platform-$arch/bun" -d "$download_path" + unzip -j "$tmpdir/bun.zip" "$bin_target/bun" -d "$download_path" ) || (rm -rf "$download_path"; fail "Failed to download Bun v$version") } diff --git a/lib/utils.bash b/lib/utils.bash index 46d0d40..89490c4 100644 --- a/lib/utils.bash +++ b/lib/utils.bash @@ -46,10 +46,12 @@ function get_arch() { esac } -function get_bin_url() { - local version=$1 - local platform=$2 - local arch=$3 +function get_bin_target() { + local platform + platform=$(get_platform) + + local arch + arch=$(get_arch) local target="$platform-$arch" if [[ "$target" = "linux-x64" ]]; then @@ -57,11 +59,16 @@ function get_bin_url() { if [[ "$(grep "avx2" < /proc/cpuinfo)" = "" ]]; then target="linux-x64-baseline" fi - fi + fi - local url="$REPO_URL/releases/download/bun-v$version/bun-$target.zip" + echo -n "bun-$target" +} + +function get_bin_url() { + local version=$1 + local target=$2 - echo -n "$url" + echo -n "$REPO_URL/releases/download/bun-v$version/$target.zip" } function get_source_url() {