mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-09-03 02:56:31 +00:00
Compare commits
4 Commits
travis_yml
...
v0.5.0
Author | SHA1 | Date | |
---|---|---|---|
![]() |
bad79e6d77 | ||
![]() |
d07fa2db10 | ||
![]() |
20953ab04c | ||
![]() |
4cf940153c |
@@ -6,13 +6,13 @@ First you'll need to make sure your system has a c++ compiler. For OSX, XCode w
|
||||
|
||||
### Install script
|
||||
|
||||
To install you could use the [install script](https://github.com/creationix/nvm/blob/v0.4.0/install.sh) using cURL:
|
||||
To install you could use the [install script](https://github.com/creationix/nvm/blob/v0.5.0/install.sh) using cURL:
|
||||
|
||||
curl https://raw.github.com/creationix/nvm/v0.4.0/install.sh | sh
|
||||
curl https://raw.github.com/creationix/nvm/v0.5.0/install.sh | sh
|
||||
|
||||
or Wget:
|
||||
|
||||
wget -qO- https://raw.github.com/creationix/nvm/v0.4.0/install.sh | sh
|
||||
wget -qO- https://raw.github.com/creationix/nvm/v0.5.0/install.sh | sh
|
||||
|
||||
<sub>The script clones the nvm repository to `~/.nvm` and adds the source line to your profile (`~/.bash_profile`, `~/.zshrc` or `~/.profile`).</sub>
|
||||
|
||||
|
39
nvm.sh
39
nvm.sh
@@ -208,7 +208,7 @@ nvm() {
|
||||
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"
|
||||
echo " nvm run <version> [<args>] Run <version> with <args> as arguments. Uses .nvmrc if available for <version>"
|
||||
echo " nvm current Display currently activated version"
|
||||
echo " nvm ls List installed versions"
|
||||
echo " nvm ls <version> List versions matching a given description"
|
||||
@@ -471,20 +471,37 @@ nvm() {
|
||||
echo "Now using node $VERSION"
|
||||
;;
|
||||
"run" )
|
||||
local provided_version
|
||||
local has_checked_nvmrc=0
|
||||
# run given version of node
|
||||
if [ $# -lt 2 ]; then
|
||||
nvm_rc_version
|
||||
if [ -z "$NVM_RC_VERSION" ]; then
|
||||
shift
|
||||
if [ $# -lt 1 ]; then
|
||||
nvm_rc_version && has_checked_nvmrc=1
|
||||
if [ -n "$NVM_RC_VERSION" ]; then
|
||||
VERSION=`nvm_version $NVM_RC_VERSION`
|
||||
else
|
||||
VERSION='N/A'
|
||||
fi
|
||||
if [ $VERSION = "N/A" ]; then
|
||||
nvm help
|
||||
return
|
||||
fi
|
||||
fi
|
||||
NVM_PROVIDED_VERSION=`nvm_version $2`
|
||||
if [ -z "$NVM_PROVIDED_VERSION" ]; then
|
||||
nvm_rc_version
|
||||
NVM_PROVIDED_VERSION="$NVM_RC_VERSION"
|
||||
|
||||
provided_version=$1
|
||||
if [ -n "$provided_version" ]; then
|
||||
VERSION=`nvm_version $provided_version`
|
||||
if [ $VERSION = "N/A" ]; then
|
||||
provided_version=''
|
||||
if [ $has_checked_nvmrc -ne 1 ]; then
|
||||
nvm_rc_version && has_checked_nvmrc=1
|
||||
fi
|
||||
VERSION=`nvm_version $NVM_RC_VERSION`
|
||||
else
|
||||
shift
|
||||
fi
|
||||
fi
|
||||
VERSION="$NVM_PROVIDED_VERSION"
|
||||
|
||||
if [ ! -d "$NVM_DIR/$VERSION" ]; then
|
||||
echo "$VERSION version is not installed yet"
|
||||
return;
|
||||
@@ -495,7 +512,7 @@ nvm() {
|
||||
RUN_NODE_PATH="$NVM_DIR/$VERSION/lib/node_modules:$NODE_PATH"
|
||||
fi
|
||||
echo "Running node $VERSION"
|
||||
NODE_PATH=$RUN_NODE_PATH $NVM_DIR/$VERSION/bin/node "${@:3}"
|
||||
NODE_PATH=$RUN_NODE_PATH $NVM_DIR/$VERSION/bin/node "$@"
|
||||
;;
|
||||
"ls" | "list" )
|
||||
nvm_print_versions "`nvm_ls $2`"
|
||||
@@ -575,7 +592,7 @@ nvm() {
|
||||
nvm_version $2
|
||||
;;
|
||||
"--version" )
|
||||
echo "nvm v0.4.0"
|
||||
echo "nvm v0.5.0"
|
||||
;;
|
||||
* )
|
||||
nvm help
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "nvm",
|
||||
"version": "0.4.0",
|
||||
"version": "0.5.0",
|
||||
"description": "Node Version Manager - Simple bash script to manage multiple active node.js versions",
|
||||
"directories": {
|
||||
"test": "test"
|
||||
|
@@ -4,21 +4,21 @@ set -e
|
||||
. ../../../nvm.sh
|
||||
|
||||
# Remove the stuff we're clobbering.
|
||||
[ -e ../../../v0.10.7 ] && rm -R ../../../v0.10.7
|
||||
[ -e ../../../v0.10.8 ] && rm -R ../../../v0.10.8
|
||||
[ -e ../../../v0.9.7 ] && rm -R ../../../v0.9.7
|
||||
[ -e ../../../v0.9.12 ] && rm -R ../../../v0.9.12
|
||||
|
||||
# Install from binary
|
||||
nvm install 0.10.7
|
||||
nvm install 0.10.8
|
||||
nvm install 0.9.7
|
||||
nvm install 0.9.12
|
||||
|
||||
# Check
|
||||
[ -d ../../../v0.10.7 ]
|
||||
[ -d ../../../v0.10.8 ]
|
||||
[ -d ../../../v0.9.7 ]
|
||||
[ -d ../../../v0.9.12 ]
|
||||
|
||||
# Use the first one
|
||||
nvm use 0.10.7
|
||||
nvm use 0.9.7
|
||||
|
||||
# Use the latest one
|
||||
nvm use 0.10
|
||||
node --version | grep v0.10.8
|
||||
nvm use 0.9
|
||||
node --version | grep v0.9.12
|
||||
|
||||
|
9
test/slow/nvm run/Running "nvm run 0.x" should work
Executable file
9
test/slow/nvm run/Running "nvm run 0.x" should work
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
[ "$(nvm run 0.10.7 --version | tail -1)" = "v0.10.7" ] || die "`nvm run` failed to run with the correct version"
|
||||
|
12
test/slow/nvm run/Running "nvm run" should pick up .nvmrc version
Executable file
12
test/slow/nvm run/Running "nvm run" should pick up .nvmrc version
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
echo "0.10.7" > .nvmrc
|
||||
[ "$(nvm run --version | tail -1)" = "v0.10.7" ] || die "`nvm run` failed to run with the .nvmrc version"
|
||||
|
||||
[ "$(nvm run --version | head -1)" = "Found .nvmrc files with version <0.10.7>" ] || die "`nvm run` failed to print out the \"found in .nvmrc\" message"
|
||||
|
9
test/slow/nvm run/setup_dir
Executable file
9
test/slow/nvm run/setup_dir
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ../../../nvm.sh
|
||||
nvm install 0.10.7
|
||||
|
||||
if [ -f ".nvmrc" ]; then
|
||||
mv .nvmrc .nvmrc.bak
|
||||
fi
|
||||
|
11
test/slow/nvm run/teardown_dir
Executable file
11
test/slow/nvm run/teardown_dir
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ../../../nvm.sh
|
||||
nvm uninstall v0.10.7
|
||||
|
||||
rm .nvmrc
|
||||
|
||||
if [ -f ".nvmrc.bak" ]; then
|
||||
mv .nvmrc.bak .nvmrc
|
||||
fi
|
||||
|
Reference in New Issue
Block a user