Skip to content

Instantly share code, notes, and snippets.

@LukeChannings
Last active January 5, 2024 02:31
Show Gist options
  • Save LukeChannings/09d53f5c364391042186518c8598b85e to your computer and use it in GitHub Desktop.
Save LukeChannings/09d53f5c364391042186518c8598b85e to your computer and use it in GitHub Desktop.
Deno installation script
#!/bin/sh
# A modification of the standard Deno installation script (https://deno.land/install.sh)
# updated to support downloading a Linux arm64 binary from LukeChannings/deno-arm64
# MIT licence.
set -e
if ! command -v unzip >/dev/null; then
echo "Error: unzip is required to install Deno (see: https://github.com/denoland/deno_install#unzip-is-required)." 1>&2
exit 1
fi
repo="denoland/deno"
if [ "$OS" = "Windows_NT" ]; then
target="x86_64-pc-windows-msvc"
else
case $(uname -sm) in
"Darwin x86_64") target="x86_64-apple-darwin" ;;
"Darwin arm64") target="aarch64-apple-darwin" ;;
"Linux aarch64")
repo="LukeChannings/deno-arm64"
target="linux-arm64"
;;
"Linux armhf")
echo "32-bit ARM is not supported. Please check your hardware and install a 64-bit operating system."
exit 1
;;
*) target="x86_64-unknown-linux-gnu" ;;
esac
fi
if [ $# -eq 0 ]; then
deno_uri="https://github.com/${repo}/releases/latest/download/deno-${target}.zip"
else
deno_uri="https://github.com/${repo}/releases/download/${1}/deno-${target}.zip"
fi
deno_install="${DENO_INSTALL:-$HOME/.deno}"
bin_dir="$deno_install/bin"
exe="$bin_dir/deno"
if [ ! -d "$bin_dir" ]; then
mkdir -p "$bin_dir"
fi
curl --fail --location --progress-bar --output "$exe.zip" "$deno_uri"
unzip -d "$bin_dir" -o "$exe.zip"
chmod +x "$exe"
rm "$exe.zip"
echo "Deno was installed successfully to $exe"
if command -v deno >/dev/null; then
echo "Run 'deno --help' to get started"
else
case $SHELL in
/bin/zsh) shell_profile=".zshrc" ;;
*) shell_profile=".bashrc" ;;
esac
echo "Manually add the directory to your \$HOME/$shell_profile (or similar)"
echo " export DENO_INSTALL=\"$deno_install\""
echo " export PATH=\"\$DENO_INSTALL/bin:\$PATH\""
echo "Run '$exe --help' to get started"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment