diff --git a/denow b/denow index 50900df..938d933 100644 --- a/denow +++ b/denow @@ -1,7 +1,6 @@ #!/bin/sh set -e deno_version="$__DENO_VERSION__" -# https://stackoverflow.com/questions/29832037/how-to-get-script-directory-in-posix-sh dir=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd) if [ ! -d "$dir/.deno" ]; then if ! o=$(curl -fsSL https://deno.land/install.sh | DENO_INSTALL="$dir/.deno" sh -s "v$deno_version" 2>&1); then diff --git a/install.sh b/install.sh index 7b14414..d137018 100755 --- a/install.sh +++ b/install.sh @@ -7,10 +7,12 @@ else base_url='https://deno.land/x/denow/' fi -if [ "$OS" = "Windows_NT" ]; then - pwsh -Command "v='$1'; irm ${DENOW_DL_BASE_URL}/install.ps1 | iex" - exit 0 -fi +# https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c +get_latest_release() { + curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api + grep '"tag_name":' | # Get tag line + sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value +} if command -v curl 2> /dev/null; then curl -fsSL "${base_url}denow.bat" -o ./denow.bat @@ -27,8 +29,7 @@ chmod +x ./denow if [ -n "$1" ]; then deno_version="$1" elif command -v grep 2> /dev/null; then - # https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c - deno_version=$(curl --silent "https://api.github.com/repos/denoland/deno/releases/latest" | grep -Po "(?<=\"tag_name\": \"v).*(?=\")") + deno_version=$(get_latest_release denoland/deno) else echo "Unable to fetch latest version" >&2 exit 1