Skip to content

Commit

Permalink
Add --version flag to install script (#1928)
Browse files Browse the repository at this point in the history
* Add `--version` flag to install script

* Lower case variable names

* Declare `latest_url` as a local
  • Loading branch information
naganowl authored and Daniel15 committed Nov 18, 2016
1 parent 6cee0fc commit 5be113b
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions scripts/install-latest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ yarn_get_tarball() {
printf "$cyan> Downloading tarball...$reset\n"
if [ "$1" = '--nightly' ]; then
url=https://nightly.yarnpkg.com/latest.tar.gz
elif [ "$1" = '--version' ]; then
url="https://yarnpkg.com/downloads/$2/yarn-v$2.tar.gz"
else
url=https://yarnpkg.com/latest.tar.gz
fi
Expand Down Expand Up @@ -107,16 +109,25 @@ yarn_install() {

if [ -d "$HOME/.yarn" ]; then
if [ -n `which yarn` ]; then
local latest_url
local specified_version
local version_type
if [ "$1" = '--nightly' ]; then
latest_url=https://nightly.yarnpkg.com/latest-tar-version
specified_version=`curl $latest_url`
version_type='latest'
elif [ "$1" = '--version' ]; then
specified_version=$2
version_type='specified'
else
latest_url=https://yarnpkg.com/latest-version
specified_version=`curl $latest_url`
version_type='latest'
fi
LATEST_VERSION=`curl $latest_url`
YARN_VERSION=`yarn -V`

if [ "$LATEST_VERSION" -eq "$YARN_VERSION" ]; then
printf "$green> Yarn is already at the latest version.$reset\n"
yarn_version=`yarn -V`
yarn_alt_version=`yarn --version`
if [ "$specified_version" = "$yarn_version" -o "$specified_version" = "$yarn_alt_version" ]; then
printf "$green> Yarn is already at the $specified_version version.$reset\n"
else
rm -rf "$HOME/.yarn"
fi
Expand All @@ -127,10 +138,10 @@ yarn_install() {
fi
fi

yarn_get_tarball $1
yarn_get_tarball $1 $2
yarn_link
yarn_reset
}

cd ~
yarn_install $1
yarn_install $1 $2

0 comments on commit 5be113b

Please sign in to comment.