Make sure `nvm install` works without a version argument when .nvmrc specifies a version.
parent
eb6031cb58
commit
bf8abf1052
29
nvm.sh
29
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,9 +247,13 @@ nvm() {
|
|||
fi
|
||||
|
||||
if [ $# -lt 2 ]; then
|
||||
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_rc_version
|
||||
if [ -z "$NVM_RC_VERSION" ]; then
|
||||
nvm help
|
||||
return
|
||||
fi
|
||||
VERSION=`nvm_version $2`
|
||||
fi
|
||||
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