Skip to content

Commit 8db5353

Browse files
committed
fix target determination
Fixes #21
1 parent 8491f02 commit 8db5353

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

bin/download

+4-7
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,11 @@ function download_version() {
1212
local version=$1
1313
local download_path=$2
1414

15-
local platform
16-
platform=$(get_platform)
17-
18-
local arch
19-
arch=$(get_arch)
15+
local bin_target
16+
bin_target=$(get_bin_target)
2017

2118
local bin_url
22-
bin_url=$(get_bin_url "$version" "$platform" "$arch")
19+
bin_url=$(get_bin_url "$version" "$bin_target")
2320

2421
local tmpdir
2522
tmpdir=$(get_temp_dir)
@@ -31,7 +28,7 @@ function download_version() {
3128
echo "Downloading Bun v$version..."
3229
curl "${curl_opts[@]}" -o "$tmpdir/bun.zip" "$bin_url" || fail "Couldn't download the Bun binary from $bin_url"
3330

34-
unzip -j "$tmpdir/bun.zip" "bun-$platform-$arch/bun" -d "$download_path"
31+
unzip -j "$tmpdir/bun.zip" "$bin_target/bun" -d "$download_path"
3532
) || (rm -rf "$download_path"; fail "Failed to download Bun v$version")
3633
}
3734

lib/utils.bash

+14-7
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,29 @@ function get_arch() {
4646
esac
4747
}
4848

49-
function get_bin_url() {
50-
local version=$1
51-
local platform=$2
52-
local arch=$3
49+
function get_bin_target() {
50+
local platform
51+
platform=$(get_platform)
52+
53+
local arch
54+
arch=$(get_arch)
5355

5456
local target="$platform-$arch"
5557
if [[ "$target" = "linux-x64" ]]; then
5658
# See https://github.com/cometkim/asdf-bun/issues/21
5759
if [[ "$(grep "avx2" < /proc/cpuinfo)" = "" ]]; then
5860
target="linux-x64-baseline"
5961
fi
60-
fi
62+
fi
6163

62-
local url="$REPO_URL/releases/download/bun-v$version/bun-$target.zip"
64+
echo -n "bun-$target"
65+
}
66+
67+
function get_bin_url() {
68+
local version=$1
69+
local target=$2
6370

64-
echo -n "$url"
71+
echo -n "$REPO_URL/releases/download/bun-v$version/$target.zip"
6572
}
6673

6774
function get_source_url() {

0 commit comments

Comments
 (0)