Merge pull request #398 from creationix/install_use_nvmrc
`nvm install` and `nvm run` use .nvmrc when version not providedmaster
commit
7976a1343f
37
nvm.sh
37
nvm.sh
|
@ -205,7 +205,7 @@ nvm() {
|
|||
echo "Usage:"
|
||||
echo " nvm help Show this message"
|
||||
echo " nvm --version Print out the latest released version of nvm"
|
||||
echo " nvm install [-s] <version> Download and install a <version>, [-s] from source"
|
||||
echo " nvm install [-s] <version> Download and install a <version>, [-s] from source. Uses .nvmrc if available"
|
||||
echo " nvm uninstall <version> Uninstall a version"
|
||||
echo " nvm use <version> Modify PATH to use <version>. Uses .nvmrc if available"
|
||||
echo " nvm run <version> [<args>] Run <version> with <args> as arguments"
|
||||
|
@ -238,6 +238,8 @@ nvm() {
|
|||
local sum
|
||||
local tarball
|
||||
local nobinary
|
||||
local version_not_provided=0
|
||||
local provided_version
|
||||
|
||||
if ! nvm_has "curl"; then
|
||||
echo 'NVM Needs curl to proceed.' >&2;
|
||||
|
@ -245,8 +247,12 @@ nvm() {
|
|||
fi
|
||||
|
||||
if [ $# -lt 2 ]; then
|
||||
nvm help
|
||||
return
|
||||
version_not_provided=1
|
||||
nvm_rc_version
|
||||
if [ -z "$NVM_RC_VERSION" ]; then
|
||||
nvm help
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
shift
|
||||
|
@ -261,9 +267,16 @@ nvm() {
|
|||
nobinary=1
|
||||
fi
|
||||
|
||||
[ -d "$NVM_DIR/$1" ] && echo "$1 is already installed." && return
|
||||
provided_version=$1
|
||||
if [ -z "$provided_version" ]; then
|
||||
if [ $version_not_provided -ne 1 ]; then
|
||||
nvm_rc_version
|
||||
fi
|
||||
provided_version="$NVM_RC_VERSION"
|
||||
fi
|
||||
[ -d "$NVM_DIR/$provided_version" ] && echo "$provided_version is already installed." && return
|
||||
|
||||
VERSION=`nvm_remote_version $1`
|
||||
VERSION=`nvm_remote_version $provided_version`
|
||||
ADDITIONAL_PARAMETERS=''
|
||||
|
||||
shift
|
||||
|
@ -460,10 +473,18 @@ nvm() {
|
|||
"run" )
|
||||
# run given version of node
|
||||
if [ $# -lt 2 ]; then
|
||||
nvm help
|
||||
return
|
||||
nvm_rc_version
|
||||
if [ -z "$NVM_RC_VERSION" ]; then
|
||||
nvm help
|
||||
return
|
||||
fi
|
||||
fi
|
||||
VERSION=`nvm_version $2`
|
||||
NVM_PROVIDED_VERSION=`nvm_version $2`
|
||||
if [ -z "$NVM_PROVIDED_VERSION" ]; then
|
||||
nvm_rc_version
|
||||
NVM_PROVIDED_VERSION="$NVM_RC_VERSION"
|
||||
fi
|
||||
VERSION="$NVM_PROVIDED_VERSION"
|
||||
if [ ! -d "$NVM_DIR/$VERSION" ]; then
|
||||
echo "$VERSION version is not installed yet"
|
||||
return;
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
. ../../../nvm.sh
|
||||
|
||||
NVM_TEST_VERSION=v0.10.7
|
||||
|
||||
# Remove the stuff we're clobbering.
|
||||
[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION
|
||||
|
||||
# Install from binary
|
||||
cat "$NVM_TEST_VERSION" > .nvmrc
|
||||
|
||||
nvm install
|
||||
|
||||
# Check
|
||||
[ -d ../../../$NVM_TEST_VERSION ]
|
||||
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION
|
||||
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
. ../../../nvm.sh
|
||||
|
||||
NVM_TEST_VERSION=v0.10.7
|
||||
|
||||
# Remove the stuff we're clobbering.
|
||||
[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION
|
||||
|
||||
# Install from binary
|
||||
cat "$NVM_TEST_VERSION" > .nvmrc
|
||||
|
||||
nvm install -s
|
||||
|
||||
# Check
|
||||
[ -d ../../../$NVM_TEST_VERSION ]
|
||||
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION
|
||||
|
||||
|
Loading…
Reference in New Issue