Merge pull request #398 from creationix/install_use_nvmrc
Before adoption: this commit came in with the history the project adopted, so no landing records it.
`nvm install` and `nvm run` use .nvmrc when version not provided
authored by Jordan Harband · committed by Jordan Harband · parents eb6031c, bf8abf1 · Browse files · 3 files·+69 added−8 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+69 added−8 removed
- tests:+40 added−0 removed
- other:+29 added−8 removed
Provenance
- Commit
7976a13- Tree
bd296c2- Author
Jordan Harband <ljharb@gmail.com>- Committer
Jordan Harband <ljharb@gmail.com>- Parent 1
eb6031c- Parent 2
bf8abf1
3 files changed+69 added−8 removed
added:test/slow/nvm install/install version specified in .nvmrc from binary+20 added
1+#!/bin/sh2+3+set -e4+. ../../../nvm.sh5+6+NVM_TEST_VERSION=v0.10.77+8+# Remove the stuff we're clobbering.9+[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION10+11+# Install from binary12+cat "$NVM_TEST_VERSION" > .nvmrc13+14+nvm install15+16+# Check17+[ -d ../../../$NVM_TEST_VERSION ]18+nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION19+20+added:test/slow/nvm install/install version specified in .nvmrc from source+20 added
1+#!/bin/sh2+3+set -e4+. ../../../nvm.sh5+6+NVM_TEST_VERSION=v0.10.77+8+# Remove the stuff we're clobbering.9+[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION10+11+# Install from binary12+cat "$NVM_TEST_VERSION" > .nvmrc13+14+nvm install -s15+16+# Check17+[ -d ../../../$NVM_TEST_VERSION ]18+nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION19+20+modified:nvm.sh+29 added-8 removed
203 unmodified lines204 echo205 echo "Usage:"206 echo " nvm help Show this message"207 echo " nvm --version Print out the latest released version of nvm"208- echo " nvm install [-s] <version> Download and install a <version>, [-s] from source"208+ echo " nvm install [-s] <version> Download and install a <version>, [-s] from source. Uses .nvmrc if available"209 echo " nvm uninstall <version> Uninstall a version"210 echo " nvm use <version> Modify PATH to use <version>. Uses .nvmrc if available"211 echo " nvm run <version> [<args>] Run <version> with <args> as arguments"212 echo " nvm current Display currently activated version"24 unmodified lines237 local url238 local sum239 local tarball240 local nobinary241+ local version_not_provided=0242+ local provided_version243 244 if ! nvm_has "curl"; then245 echo 'NVM Needs curl to proceed.' >&2;246 return 1247 fi248 249 if [ $# -lt 2 ]; then250+ version_not_provided=1251+ nvm_rc_version252+ if [ -z "$NVM_RC_VERSION" ]; then248- nvm help249- return253+ nvm help254+ return255+ fi256 fi257 258 shift259 6 unmodified lines266 if [ "$os" = "freebsd" ]; then267 nobinary=1268 fi269 264- [ -d "$NVM_DIR/$1" ] && echo "$1 is already installed." && return270+ provided_version=$1271+ if [ -z "$provided_version" ]; then272+ if [ $version_not_provided -ne 1 ]; then273+ nvm_rc_version274+ fi275+ provided_version="$NVM_RC_VERSION"276+ fi277+ [ -d "$NVM_DIR/$provided_version" ] && echo "$provided_version is already installed." && return278 266- VERSION=`nvm_remote_version $1`279+ VERSION=`nvm_remote_version $provided_version`280 ADDITIONAL_PARAMETERS=''281 282 shift283 188 unmodified lines472 ;;473 "run" )474 # run given version of node475 if [ $# -lt 2 ]; then476+ nvm_rc_version477+ if [ -z "$NVM_RC_VERSION" ]; then463- nvm help464- return478+ nvm help479+ return480+ fi481 fi466- VERSION=`nvm_version $2`482+ NVM_PROVIDED_VERSION=`nvm_version $2`483+ if [ -z "$NVM_PROVIDED_VERSION" ]; then484+ nvm_rc_version485+ NVM_PROVIDED_VERSION="$NVM_RC_VERSION"486+ fi487+ VERSION="$NVM_PROVIDED_VERSION"488 if [ ! -d "$NVM_DIR/$VERSION" ]; then489 echo "$VERSION version is not installed yet"490 return;491 fi96 unmodified lines