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 "Usage:"
|
||||||
echo " nvm help Show this message"
|
echo " nvm help Show this message"
|
||||||
echo " nvm --version Print out the latest released version of nvm"
|
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 uninstall <version> Uninstall a version"
|
||||||
echo " nvm use <version> Modify PATH to use <version>. Uses .nvmrc if available"
|
echo " nvm use <version> Modify PATH to use <version>. Uses .nvmrc if available"
|
||||||
echo " nvm run <version> [<args>] Run <version> with <args> as arguments"
|
echo " nvm run <version> [<args>] Run <version> with <args> as arguments"
|
||||||
|
@ -238,6 +238,8 @@ nvm() {
|
||||||
local sum
|
local sum
|
||||||
local tarball
|
local tarball
|
||||||
local nobinary
|
local nobinary
|
||||||
|
local version_not_provided=0
|
||||||
|
local provided_version
|
||||||
|
|
||||||
if ! nvm_has "curl"; then
|
if ! nvm_has "curl"; then
|
||||||
echo 'NVM Needs curl to proceed.' >&2;
|
echo 'NVM Needs curl to proceed.' >&2;
|
||||||
|
@ -245,8 +247,12 @@ nvm() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $# -lt 2 ]; then
|
if [ $# -lt 2 ]; then
|
||||||
nvm help
|
version_not_provided=1
|
||||||
return
|
nvm_rc_version
|
||||||
|
if [ -z "$NVM_RC_VERSION" ]; then
|
||||||
|
nvm help
|
||||||
|
return
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
shift
|
shift
|
||||||
|
@ -261,9 +267,16 @@ nvm() {
|
||||||
nobinary=1
|
nobinary=1
|
||||||
fi
|
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=''
|
ADDITIONAL_PARAMETERS=''
|
||||||
|
|
||||||
shift
|
shift
|
||||||
|
@ -460,10 +473,18 @@ nvm() {
|
||||||
"run" )
|
"run" )
|
||||||
# run given version of node
|
# run given version of node
|
||||||
if [ $# -lt 2 ]; then
|
if [ $# -lt 2 ]; then
|
||||||
nvm help
|
nvm_rc_version
|
||||||
return
|
if [ -z "$NVM_RC_VERSION" ]; then
|
||||||
|
nvm help
|
||||||
|
return
|
||||||
|
fi
|
||||||
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
|
if [ ! -d "$NVM_DIR/$VERSION" ]; then
|
||||||
echo "$VERSION version is not installed yet"
|
echo "$VERSION version is not installed yet"
|
||||||
return;
|
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