diff --git a/.envrc b/.envrc index 58e53d0..58ad4b3 100644 --- a/.envrc +++ b/.envrc @@ -1,25 +1,22 @@ export PATH="$(git rev-parse --show-toplevel)/bin:$PATH" -err() { - >&2 echo "$*" - exit 1 -} - -goos=$(uname | tr A-Z a-z) +[[ -x bin/bazel ]] && exit case $(uname -m) in - x86_64) goarch=amd64;; - aarch64) goarch=arm64;; - *) err "unsupported architecture $(uname -m)" + x86_64) + goarch=amd64;; + aarch64) + goarch=arm64;; + *) + >&2 echo "unsupported architecture $(uname -m)" + exit 1;; esac -if [[ -x bin/bazel ]]; then - exit -fi +bzl="bazelisk-$(uname | tr A-Z a-z)-${goarch}" -rm -f "bin/bazelisk-${goos}-${goarch}" -wget --no-verbose "https://github.com/bazelbuild/bazelisk/releases/download/v1.10.1/bazelisk-${goos}-${goarch}" \ - -O "bin/bazelisk-${goos}-${goarch}" +rm -f "bin/$bzl" +wget --no-verbose "https://github.com/bazelbuild/bazelisk/releases/download/v1.10.1/$bzl" \ + -O "bin/$bzl" sha256sum -c --ignore-missing <<-EOF e485bbf84532d02a60b0eb23c702610b5408df3a199087a4f2b5e0995bbf2d5a bin/bazelisk-darwin-amd64 @@ -28,5 +25,5 @@ c22d48601466d9d3b043ccd74051f2f4230f9b9f4509f097017c97303aa88d13 bin/bazelisk-d c1de6860dd4f8d5e2ec270097bd46d6a211b971a0b8b38559784bd051ea950a1 bin/bazelisk-linux-arm64 EOF -chmod a+x "bin/bazelisk-${goos}-${goarch}" -mv "bin/bazelisk-${goos}-${goarch}" bin/bazel +chmod a+x "bin/$bzl" +mv "bin/$bzl" bin/bazel