From 9ff2b1432a5eba9c0dce5f494cc4271227bf61ba Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Tue, 15 Jan 2019 19:43:12 -0500 Subject: [PATCH] Clean up install.sh and bump to v0.2.7 (#27) --- .travis.yml | 24 +++--------------------- install.sh | 29 ++++++++++++++++------------- install_test.sh | 41 +++++++++-------------------------------- 3 files changed, 28 insertions(+), 66 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8cf9015..9c3939e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ matrix: - ./install.py - ./install_test.py - - language: sh + - language: bash os: - linux addons: @@ -31,25 +31,7 @@ matrix: - curl --version - shellcheck --version - curl -sSL "$SHFMT_DOWNLOAD_URL" -o $HOME/bin/shfmt; - chmod +x $HOME/bin/shfmt; - shfmt --version - script: - - echo "Linting installer script using \`shellcheck\`:"; - shellcheck -s sh *.sh; - shellcheck -s dash *.sh; - shellcheck -s ksh *.sh; - shellcheck -s bash *.sh - - echo "Checking script formatting using \`shfmt\`:"; - shfmt -d -p -i 2 -ci . - - echo "Running test suite inside supported shells:"; - echo "\`sh\`:"; sh ./install_test.sh; - echo "\`dash\`:"; dash ./install_test.sh; - echo "\`ksh\`:"; ksh ./install_test.sh; - echo "\`bash\`:"; bash ./install_test.sh; - echo "\`zsh\`:"; zsh ./install_test.sh - - - language: bash - os: - - osx + - chmod +x $HOME/bin/shfmt; + - shfmt --version script: - ./install_test.sh diff --git a/install.sh b/install.sh index 3792707..e70760e 100755 --- a/install.sh +++ b/install.sh @@ -5,31 +5,34 @@ set -e if [ $# -eq 0 ]; then - version="v0.2.6" + version="v0.2.7" else - version=$1 + version=$1 fi -deno_dir="$HOME/.deno/bin" +bin_dir="$HOME/.deno/bin" +exe="$bin_dir/deno" -if [ ! -d "$deno_dir" ]; then - mkdir -p "$deno_dir" +if [ ! -d "$bin_dir" ]; then + mkdir -p "$bin_dir" fi case $(uname -s) in - Darwin) os="osx" ;; - *) os="linux" ;; +Darwin) os="osx" ;; +*) os="linux" ;; esac deno_uri="https://github.com/denoland/deno/releases/download/${version}/deno_${os}_x64.gz" -curl -fL# -o "$deno_dir/deno.gz" "$deno_uri" -gunzip -df "$deno_dir/deno.gz" -chmod +x "$deno_dir/deno" +curl -fL# -o "$exe.gz" "$deno_uri" +gunzip -df "$exe.gz" +chmod +x "$exe" -echo "Deno was installed successfully." +echo "Deno was installed successfully to $exe" if command -v deno >/dev/null; then - echo "Run 'deno --help' to get started." + echo "Run 'deno --help' to get started." else - echo "Run '~/.deno/bin/deno --help' to get started." + echo "Manually add the directory to your \$HOME/.bash_profile (or similar)" + echo " export PATH=\"$bin_dir:\$PATH\"" + echo "Run '$exe --help' to get started." fi diff --git a/install_test.sh b/install_test.sh index 5cb72bb..f666465 100755 --- a/install_test.sh +++ b/install_test.sh @@ -1,40 +1,17 @@ #!/bin/sh -set -e -chmod +x install.sh +set -ev -# PATH tests - -rm -rf ~/.deno -./install.sh | grep -e "Run '~/.deno/bin/deno --help' to get started." -~/.deno/bin/deno --help - -PATH=$PATH:~/.deno/bin -rm -rf ~/.deno -./install.sh | grep -e "Run 'deno --help' to get started." -deno --help - -# Version tests +# Lint. +shellcheck -s sh ./*.sh +shfmt -d . +# Test we can install a specific version rm -rf ~/.deno ./install.sh v0.2.0 -deno -v | grep -e 0.2.0 - -# End-to-end tests - -if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then - repo=$TRAVIS_REPO_SLUG - branch=$TRAVIS_BRANCH -else - repo=$TRAVIS_PULL_REQUEST_SLUG - branch=$TRAVIS_PULL_REQUEST_BRANCH -fi -e2e_url=https://raw.githubusercontent.com/$repo/$branch/install.sh +~/.deno/bin/deno -v | grep -e 0.2.0 +# Test we can get the latest version. rm -rf ~/.deno -curl -sSL "$e2e_url" | $SHELL -deno -v - -rm -rf ~/.deno -curl -sSL "$e2e_url" | $SHELL -s v0.2.0 -deno -v | grep -e 0.2.0 +sh ./install.sh +~/.deno/bin/deno -v