diff --git a/.travis.yml b/.travis.yml index 19978b0..8cf9015 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,55 @@ -language: python +matrix: + include: + - language: python + os: + - linux + # Travis does not support python on osx yet. + # see: https://github.com/travis-ci/travis-ci/issues/2312 + # - osx + python: + - "2.7" + - "3.3" + # Test the install script. + script: + - ./install.py + - ./install_test.py -os: - - linux - # Travis does not support python on osx yet. - # see: https://github.com/travis-ci/travis-ci/issues/2312 - # - osx + - language: sh + os: + - linux + addons: + apt: + packages: + - ksh + - zsh + env: + - PATH=$HOME/bin/:$PATH + - SHFMT_VERSION=v2.6.2 + - SHFMT_DOWNLOAD_URL="https://github.com/mvdan/sh/releases/download/${SHFMT_VERSION}/shfmt_${SHFMT_VERSION}_linux_amd64" + before_script: + - $SHELL --version 2>/dev/null || dpkg -s "$SHELL" 2>/dev/null || command -v "$SHELL" + - 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 -python: - - "2.7" - - "3.3" - -# Test the install script. -script: - - ./install.py - - ./install_test.py + - language: bash + os: + - osx + script: + - ./install_test.sh diff --git a/README.md b/README.md index 5c494f1..e814d81 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,15 @@ Downloads the latest Deno binary into `$HOME/.deno/bin`. +**Install with Shell:** + +```sh +curl -L https://deno.land/x/install/install.sh | sh +``` + **Install with Python:** -``` +```sh curl -L https://deno.land/x/install/install.py | python ``` @@ -24,9 +30,15 @@ _Note: Depending on your security settings, you may have to run `Set-ExecutionPo If you need to install specific version of deno, use the following commands: +**Install with Shell:** + +```sh +curl -L https://deno.land/x/install/install.sh | sh -s v0.2.0 +``` + **Install with Python:** -``` +```sh curl -L https://deno.land/x/install/install.py | python - v0.2.0 ``` diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..3792707 --- /dev/null +++ b/install.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# Copyright 2018 the Deno authors. All rights reserved. MIT license. +# TODO(everyone): Keep this script simple and easily auditable. + +set -e + +if [ $# -eq 0 ]; then + version="v0.2.6" +else + version=$1 +fi + +deno_dir="$HOME/.deno/bin" + +if [ ! -d "$deno_dir" ]; then + mkdir -p "$deno_dir" +fi + +case $(uname -s) in + 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" + +echo "Deno was installed successfully." +if command -v deno >/dev/null; then + echo "Run 'deno --help' to get started." +else + echo "Run '~/.deno/bin/deno --help' to get started." +fi diff --git a/install_test.sh b/install_test.sh new file mode 100755 index 0000000..5cb72bb --- /dev/null +++ b/install_test.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +set -e +chmod +x install.sh + +# 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 + +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 + +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