Compare commits

..

44 Commits

Author SHA1 Message Date
Jordan Harband
bad79e6d77 v0.5.0 2014-04-20 00:36:12 -07:00
Jordan Harband
d07fa2db10 Merge pull request #399 from creationix/run_use_nvmrc
Make sure `nvm run` works without a version argument when .nvmrc specifies a version
2014-04-20 00:35:59 -07:00
Jordan Harband
20953ab04c Make sure nvm run works without a version argument when .nvmrc specifies a version. 2014-04-20 00:28:07 -07:00
Jordan Harband
4cf940153c Use node 0.9 for these testsso that people aren't likely to have it installed 2014-04-19 23:41:36 -07:00
Jordan Harband
47bbf93f50 Travis CI defaults to ruby; c will be faster 2014-04-19 22:59:30 -07:00
Jordan Harband
7976a1343f Merge pull request #398 from creationix/install_use_nvmrc
`nvm install` and `nvm run` use .nvmrc when version not provided
2014-04-19 22:36:33 -07:00
Jordan Harband
bf8abf1052 Make sure nvm install works without a version argument when .nvmrc specifies a version. 2014-04-19 17:07:00 -07:00
Jordan Harband
eb6031cb58 Clean up after existing nvm install tests. 2014-04-19 17:00:06 -07:00
Jordan Harband
55a6f1f06e Organizing nvm install tests better. 2014-04-19 16:48:43 -07:00
Jordan Harband
c188c1b11a Correcting help text for nvm use 2014-04-19 16:46:22 -07:00
Jordan Harband
b15ea07067 Don't clobber the latest version of 0.10 for tests. 2014-04-19 16:46:17 -07:00
Jordan Harband
752c0e4ef1 Removing trailing whitespace. 2014-04-19 14:34:47 -07:00
Jordan Harband
49364532b3 Merge pull request #391 from koenpunt/patch-1
Link to latest version of install script (0.4.0)
2014-03-27 10:19:44 -07:00
Koen Punt
9157cb4cfe Link to latest version of install script (0.4.0) 2014-03-27 10:19:00 +01:00
Jordan Harband
6dde4aac38 v0.4.0 2014-03-26 21:31:48 -07:00
Jordan Harband
96635cd2bd Merge pull request #371 from koenpunt/single-installer
Merged installer and gitless installer into one
2014-03-26 21:30:00 -07:00
Koen Punt
5342b6a04c Emulate curl with wget 2014-03-26 11:14:09 +01:00
Koen Punt
2d0c025c49 Prevent fallback 2014-03-26 11:14:08 +01:00
Koen Punt
6ed93f4c01 Force install method by setting METHOD=git/script 2014-03-26 11:14:08 +01:00
Koen Punt
3c2719a85e fix 2014-03-26 11:14:08 +01:00
Koen Punt
c47f03f996 Display error when unable to update 2014-03-26 11:11:26 +01:00
Koen Punt
300022642a git, curl and wget now all in one installer 2014-03-25 20:53:05 +01:00
Koen Punt
bce3abaa4b use comparison opts 2014-03-25 20:52:30 +01:00
Koen Punt
9f6280265a updated README 2014-03-25 20:52:30 +01:00
Koen Punt
7211c9ee29 updated output without special characters (tab; \t)
Omit duplicate 'finish line'
normalized indentation
2014-03-25 20:51:39 +01:00
Koen Punt
246caa8581 Updated source string, use hard path as NVM is not always installed in $HOME/.nvm 2014-03-25 20:51:39 +01:00
Koen Punt
1fac49f887 replaced undocumented option for specifying the profile as first argument to specifying it as a environment variable (eg: PROFILE=~/.myprofile ./install-gitless.sh)
also; fixed indentation and added .zshrc as possible profile
2014-03-25 20:51:39 +01:00
Koen Punt
d2422a623a made NVM_DIR and NVM_SOURCE configurable using environment variables 2014-03-25 20:51:39 +01:00
Koen Punt
fcc00b22b7 don't make use of pushd and popd as they are not universal 2014-03-25 20:51:39 +01:00
Koen Punt
0787a55999 replaced fatalExit function for 'inline' exit
exit on errors (set -e)
simplified if for NVM_DIR and NVM_SOURCE, corrected indentation
2014-03-25 20:51:39 +01:00
Jordan Harband
7c45d62b37 Merge pull request #388 from koenpunt/small-fixes
Use NVM_ prefix for non local variables
2014-03-23 11:56:09 -07:00
Koen Punt
ec7909dcd3 Use NVM_ prefix for variables 2014-03-23 16:42:38 +01:00
Jordan Harband
cf5f195d75 Merge pull request #387 from koenpunt/patch-1
Add travis badge to README
2014-03-22 14:00:46 -07:00
Koen Punt
9f0520cdd0 Add travis badge to README 2014-03-22 21:19:43 +01:00
Jordan Harband
d950c1a0ea Adding a trailing newline 2014-03-22 13:10:18 -07:00
Jordan Harband
6123fbcd31 Merge pull request #386 from koenpunt/multi-shell-test
Add Makefile for multishell testing
2014-03-22 13:08:50 -07:00
Koen Punt
def7ec5364 install shells before running tests 2014-03-22 18:51:39 +01:00
Koen Punt
52a384a0cc Add Makefile for multishell testing
updated nvm current test for zsh
2014-03-22 18:47:15 +01:00
Jordan Harband
ba1e2f1cdf Merge pull request #382 from koenpunt/version-normalizing
Fix nvm ls for v* numbers
2014-03-21 09:30:19 -07:00
Jordan Harband
625e54880f Merge pull request #374 from koenpunt/fix-tests
Fix NVM_DIR discovery
2014-03-21 09:27:13 -07:00
Jordan Harband
cebda7d35a When curl is not present, immediately bail out of nvm install with a nonzero exit code. Fixes #385. 2014-03-21 09:23:30 -07:00
Koen Punt
4a9a15c404 Fix NVM_DIR discovery 2014-03-21 10:03:16 +01:00
Koen Punt
a34c080d77 Fix nvm ls for v* numbers
Previously calling nvm ls with v* number (nvm ls v0.2)
would not return any results.

So now the v is prepended if its not already there
2014-03-18 10:53:57 +01:00
Koen Punt
0b97ee1d2a Failing test for when using nvm ls with v* version 2014-03-18 10:49:44 +01:00
23 changed files with 383 additions and 212 deletions

View File

@@ -1,5 +1,8 @@
language: bash
language: c # defaults to ruby
install:
- sudo apt-get install ksh zsh -y
before_script:
- curl -o /tmp/urchin https://raw.github.com/scraperwiki/urchin/master/urchin && chmod +x /tmp/urchin
script:
- NVM_DIR=$TRAVIS_BUILD_DIR /tmp/urchin test
- NVM_DIR=$TRAVIS_BUILD_DIR make URCHIN=/tmp/urchin test

16
Makefile Normal file
View File

@@ -0,0 +1,16 @@
URCHIN=`which urchin`
SHELLS=sh bash dash ksh zsh
.PHONY: $(SHELLS) test
fast: $(SHELLS)
$(SHELLS):
@printf '\n\033[0;34m%s\033[0m\n' "Running tests in $@"
@$@ $(URCHIN) -f test/fast
test: fast
@$(URCHIN) -f test/slow
default: test

View File

@@ -1,4 +1,4 @@
# Node Version Manager
# Node Version Manager [![Build Status](https://travis-ci.org/creationix/nvm.svg?branch=master)](https://travis-ci.org/creationix/nvm)
## Installation
@@ -6,16 +6,19 @@ 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.3.0/install.sh) (requires Git) 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.3.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.3.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` or `~/.profile`).</sub>
<sub>The script clones the nvm repository to `~/.nvm` and adds the source line to your profile (`~/.bash_profile`, `~/.zshrc` or `~/.profile`).</sub>
You can customize the install source, directory and profile using the `NVM_SOURCE`, `NVM_DIR` and `NVM_PROFILE` variables. Eg: `curl ... | NVM_DIR=/usr/local/nvm sh` for a global install.
<sub>*NB. The installer can use Git, cURL or Wget to download NVM, whatever is available.*</sub>
### Manual install

View File

@@ -1,69 +0,0 @@
#!/bin/bash
fatalExit (){
echo "$@" && exit 1;
}
# an alternative URL that could be used: https://github.com/creationix/nvm/tarball/master
if [ "$NVM_SOURCE" = "" ]; then
NVM_SOURCE="https://raw.github.com/creationix/nvm/master/nvm.sh"
fi
if [ "$NVM_DIR" = "" ]; then
NVM_DIR="$HOME/.nvm"
fi
# Downloading to $NVM_DIR
mkdir -p "$NVM_DIR"
pushd "$NVM_DIR" > /dev/null
echo -ne "=> Downloading... "
# Detect if curl or wget is installed to download NVM_SOURCE
if type curl > /dev/null 2>&1; then
curl --silent "$NVM_SOURCE" -o nvm.sh || fatalExit "Failed";
elif type wget > /dev/null 2>&1; then
wget --quiet "$NVM_SOURCE" -O nvm.sh || fatalExit "Failed";
else
fatalExit "Must have curl or wget to install nvm";
fi
echo "Downloaded"
popd > /dev/null
# Detect profile file, .bash_profile has precedence over .profile
if [ ! -z "$1" ]; then
PROFILE="$1"
else
if [ -f "$HOME/.bash_profile" ]; then
PROFILE="$HOME/.bash_profile"
elif [ -f "$HOME/.profile" ]; then
PROFILE="$HOME/.profile"
fi
fi
SOURCE_STR="[[ -s "$NVM_DIR/nvm.sh" ]] && . "$NVM_DIR/nvm.sh" # This loads NVM"
if [ -z "$PROFILE" ] || [ ! -f "$PROFILE" ] ; then
if [ -z $PROFILE ]; then
echo "=> Profile not found"
else
echo "=> Profile $PROFILE not found"
fi
echo "=> Append the following line to the correct file yourself"
echo
echo "\t$SOURCE_STR"
echo
echo "=> Close and reopen your terminal to start using NVM"
exit
fi
if ! grep -qc 'nvm.sh' $PROFILE; then
echo "=> Appending source string to $PROFILE"
echo "" >> "$PROFILE"
echo $SOURCE_STR >> "$PROFILE"
else
echo "=> Source string already in $PROFILE"
fi
echo "=> Close and reopen your terminal to start using NVM"

View File

@@ -1,66 +1,130 @@
#!/bin/bash
NVM_DIR="$HOME/.nvm"
set -e
if ! hash git 2>/dev/null; then
echo >&2 "You need to install git - visit http://git-scm.com/downloads"
echo >&2 "or, use install-gitless.sh instead."
exit 1
has() {
type "$1" > /dev/null 2>&1
return $?
}
if [ -z "$NVM_DIR" ]; then
NVM_DIR="$HOME/.nvm"
fi
if [ -d "$NVM_DIR" ]; then
echo "=> NVM is already installed in $NVM_DIR, trying to update"
echo -ne "\r=> "
cd $NVM_DIR && git pull
if ! has "curl"; then
if has "wget"; then
# Emulate curl with wget
curl() {
ARGS="$* "
ARGS=${ARGS/-s /-q }
ARGS=${ARGS/-o /-O }
wget $ARGS
}
fi
fi
install_from_git() {
if [ -z "$NVM_SOURCE" ]; then
NVM_SOURCE="https://github.com/creationix/nvm.git"
fi
if [ -d "$NVM_DIR/.git" ]; then
echo "=> nvm is already installed in $NVM_DIR, trying to update"
echo -e "\r=> \c"
cd "$NVM_DIR" && git pull 2> /dev/null || {
echo >&2 "Failed to update nvm, run 'git pull' in $NVM_DIR yourself.."
}
else
# Cloning to $NVM_DIR
echo "=> Downloading nvm from git to '$NVM_DIR'"
echo -e "\r=> \c"
mkdir -p "$NVM_DIR"
git clone "$NVM_SOURCE" "$NVM_DIR"
fi
}
install_as_script() {
if [ -z "$NVM_SOURCE" ]; then
NVM_SOURCE="https://raw.github.com/creationix/nvm/master/nvm.sh"
fi
# Downloading to $NVM_DIR
mkdir -p "$NVM_DIR"
if [ -d "$NVM_DIR/nvm.sh" ]; then
echo "=> nvm is already installed in $NVM_DIR, trying to update"
else
echo "=> Downloading nvm as script to '$NVM_DIR'"
fi
curl -s "$NVM_SOURCE" -o "$NVM_DIR/nvm.sh" || {
echo >&2 "Failed to download '$NVM_SOURCE'.."
return 1
}
}
if [ -z "$METHOD" ]; then
# Autodetect install method
if has "git"; then
install_from_git
elif has "curl"; then
install_as_script
else
echo >&2 "You need git, curl or wget to install nvm"
exit 1
fi
else
# Cloning to $NVM_DIR
git clone https://github.com/creationix/nvm.git $NVM_DIR
if [ "$METHOD" = "git" ]; then
if ! has "git"; then
echo >&2 "You need git to install nvm"
exit 1
fi
install_from_git
fi
if [ "$METHOD" = "script" ]; then
if ! has "curl"; then
echo >&2 "You need curl or wget to install nvm"
exit 1
fi
install_as_script
fi
fi
echo
# Detect profile file, .bash_profile has precedence over .profile
if [ ! -z "$1" ]; then
PROFILE="$1"
else
# Detect profile file if not specified as environment variable (eg: PROFILE=~/.myprofile).
if [ -z "$PROFILE" ]; then
if [ -f "$HOME/.bash_profile" ]; then
PROFILE="$HOME/.bash_profile"
PROFILE="$HOME/.bash_profile"
elif [ -f "$HOME/.zshrc" ]; then
PROFILE="$HOME/.zshrc"
PROFILE="$HOME/.zshrc"
elif [ -f "$HOME/.profile" ]; then
PROFILE="$HOME/.profile"
PROFILE="$HOME/.profile"
fi
fi
SOURCE_STR="[[ -s \$HOME/.nvm/nvm.sh ]] && . \$HOME/.nvm/nvm.sh # This loads NVM"
SOURCE_STR="[ -s \"$NVM_DIR/nvm.sh\" ] && . \"$NVM_DIR/nvm.sh\" # This loads nvm"
if [ -z "$PROFILE" ] || [ ! -f "$PROFILE" ] ; then
if [ -z $PROFILE ]; then
echo "=> Profile not found. Tried $HOME/.bash_profile and $HOME/.profile"
echo "=> Profile not found. Tried ~/.bash_profile ~/.zshrc and ~/.profile."
echo "=> Create one of them and run this script again"
else
echo "=> Profile $PROFILE not found"
echo "=> Profile $PROFILE not found"
echo "=> Create it (touch $PROFILE) and run this script again"
fi
echo "=> Run this script again after running the following:"
echo " OR"
echo "=> Append the following line to the correct file yourself:"
echo
echo "\ttouch $HOME/.profile"
echo " $SOURCE_STR"
echo
echo "-- OR --"
echo
echo "=> Append the following line to the correct file yourself"
echo
echo "\t$SOURCE_STR"
echo
echo "=> Close and reopen your terminal afterwards to start using NVM"
exit
fi
if ! grep -qc 'nvm.sh' $PROFILE; then
echo "=> Appending source string to $PROFILE"
echo "" >> "$PROFILE"
echo $SOURCE_STR >> "$PROFILE"
else
echo "=> Source string already in $PROFILE"
if ! grep -qc 'nvm.sh' $PROFILE; then
echo "=> Appending source string to $PROFILE"
echo "" >> "$PROFILE"
echo $SOURCE_STR >> "$PROFILE"
else
echo "=> Source string already in $PROFILE"
fi
fi
echo "=> Close and reopen your terminal to start using NVM"
echo "=> Close and reopen your terminal to start using nvm"

127
nvm.sh
View File

@@ -5,6 +5,8 @@
# Implemented by Tim Caswell <tim@creationix.com>
# with much bash help from Matthew Ranney
NVM_SCRIPT_SOURCE="$_"
nvm_has() {
type "$1" > /dev/null 2>&1
return $?
@@ -17,14 +19,15 @@ if nvm_has "unsetopt"; then
NVM_CD_FLAGS="-q"
fi
# Auto detect the NVM_DIR
if [ ! -d "$NVM_DIR" ]; then
# Auto detect the NVM_DIR when not set
if [ -z "$NVM_DIR" ]; then
if [ -n "$BASH_SOURCE" ]; then
export NVM_DIR=$(cd $NVM_CD_FLAGS $(dirname ${BASH_SOURCE[0]:-$0}) > /dev/null && pwd)
else
export NVM_DIR=$HOME/.nvm
NVM_SCRIPT_SOURCE="${BASH_SOURCE[0]}"
fi
export NVM_DIR=$(cd $NVM_CD_FLAGS $(dirname "${NVM_SCRIPT_SOURCE:-$0}") > /dev/null && pwd)
fi
unset NVM_SCRIPT_SOURCE 2> /dev/null
# Setup mirror location if not already set
if [ -z "$NVM_NODEJS_ORG_MIRROR" ]; then
@@ -34,8 +37,8 @@ fi
# Obtain nvm version from rc file
nvm_rc_version() {
if [ -e .nvmrc ]; then
RC_VERSION=`cat .nvmrc | head -n 1`
echo "Found .nvmrc files with version <$RC_VERSION>"
NVM_RC_VERSION=`cat .nvmrc | head -n 1`
echo "Found .nvmrc files with version <$NVM_RC_VERSION>"
fi
}
@@ -67,6 +70,21 @@ nvm_remote_version() {
fi
}
nvm_normalize_version() {
echo "$1" | sed -e 's/^v//' | awk -F. '{ printf("%d%03d%03d\n", $1,$2,$3); }'
}
nvm_format_version() {
echo "$1" | sed -e 's/^\([0-9]\)/v\1/g'
}
nvm_binary_available() {
# binaries started with node 0.8.6
local MINIMAL="0.8.6"
local VERSION=$1
[ $(nvm_normalize_version $VERSION) -ge $(nvm_normalize_version $MINIMAL) ]
}
nvm_ls() {
local PATTERN=$1
local VERSIONS=''
@@ -83,7 +101,7 @@ nvm_ls() {
if [ `expr "$PATTERN" : "v[[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*$"` != 0 ]; then
VERSIONS="$PATTERN"
else
VERSIONS=`find "$NVM_DIR/" -maxdepth 1 -type d -name "v$PATTERN*" -exec basename '{}' ';' \
VERSIONS=`find "$NVM_DIR/" -maxdepth 1 -type d -name "$(nvm_format_version $PATTERN)*" -exec basename '{}' ';' \
| sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n`
fi
if [ -z "$VERSIONS" ]; then
@@ -99,9 +117,7 @@ nvm_ls_remote() {
local VERSIONS
local GREP_OPTIONS=''
if [ -n "$PATTERN" ]; then
if echo "${PATTERN}" | \grep -v '^v' ; then
PATTERN=v$PATTERN
fi
PATTERN=`nvm_format_version "$PATTERN"`
else
PATTERN=".*"
fi
@@ -142,7 +158,7 @@ nvm_print_versions() {
local FORMAT
local CURRENT=`nvm_version current`
echo "$1" | while read VERSION; do
if [ "$VERSION" == "$CURRENT" ]; then
if [ "$VERSION" = "$CURRENT" ]; then
FORMAT='\033[0;32m-> %9s\033[0m'
elif [ -d "$NVM_DIR/$VERSION" ]; then
FORMAT='\033[0;34m%12s\033[0m'
@@ -189,10 +205,10 @@ 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>"
echo " nvm run <version> [<args>] Run <version> with <args> as arguments"
echo " nvm use <version> Modify PATH to use <version>. Uses .nvmrc if available"
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"
@@ -222,14 +238,21 @@ 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;
return 1
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
@@ -244,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
@@ -263,14 +293,7 @@ nvm() {
if [ $nobinary -ne 1 ]; then
# shortcut - try the binary if possible.
if [ -n "$os" ]; then
binavail=
# binaries started with node 0.8.6
case "$VERSION" in
v0.8.[012345]) binavail=0 ;;
v0.[1234567].*) binavail=0 ;;
*) binavail=1 ;;
esac
if [ $binavail -eq 1 ]; then
if nvm_binary_available "$VERSION"; then
t="$VERSION-$os-$arch"
url="$NVM_NODEJS_ORG_MIRROR/$VERSION/node-${t}.tar.gz"
sum=`curl -s $NVM_NODEJS_ORG_MIRROR/$VERSION/SHASUMS.txt | \grep node-${t}.tar.gz | awk '{print $1}'`
@@ -347,12 +370,13 @@ nvm() {
;;
"uninstall" )
[ $# -ne 2 ] && nvm help && return
if [ "$2" = `nvm_version` ]; then
echo "nvm: Cannot uninstall currently-active node version, $2."
PATTERN=`nvm_format_version $2`
if [ "$PATTERN" = `nvm_version` ]; then
echo "nvm: Cannot uninstall currently-active node version, $PATTERN."
return 1
fi
VERSION=`nvm_version $2`
if [ ! -d "$NVM_DIR/$VERSION" ]; then
VERSION=`nvm_version $PATTERN`
if [ ! -d $NVM_DIR/$VERSION ]; then
echo "$VERSION version is not installed..."
return;
fi
@@ -402,8 +426,8 @@ nvm() {
fi
if [ $# -eq 1 ]; then
nvm_rc_version
if [ -n "$RC_VERSION" ]; then
VERSION=`nvm_version $RC_VERSION`
if [ -n "$NVM_RC_VERSION" ]; then
VERSION=`nvm_version $NVM_RC_VERSION`
fi
else
VERSION=`nvm_version $2`
@@ -447,12 +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 help
return
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
VERSION=`nvm_version $2`
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
if [ ! -d "$NVM_DIR/$VERSION" ]; then
echo "$VERSION version is not installed yet"
return;
@@ -463,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`"
@@ -543,7 +592,7 @@ nvm() {
nvm_version $2
;;
"--version" )
echo "nvm v0.3.0"
echo "nvm v0.5.0"
;;
* )
nvm help

View File

@@ -1,6 +1,6 @@
{
"name": "nvm",
"version": "0.2.0",
"version": "0.5.0",
"description": "Node Version Manager - Simple bash script to manage multiple active node.js versions",
"directories": {
"test": "test"

View File

@@ -7,4 +7,6 @@ mkdir ../../../v0.2.3
# The result should contain only the appropriate version numbers.
nvm ls 0.2 | grep v0.2.3 &&
nvm ls 0.1 | grep -v v0.2.3
nvm ls 0.1 | grep -v v0.2.3 &&
nvm ls 0.1 | grep v0.1.3 &&
nvm ls v0.2 | grep v0.2.3

View File

@@ -3,4 +3,4 @@
die () { echo $@ ; exit 1; }
. ../../nvm.sh
[ "$(nvm current)" = `node -v` ] || die "Failed to find current version"
[ "$(nvm current)" = "$(node -v)" ] || die "Failed to find current version"

View File

@@ -1,16 +0,0 @@
#!/bin/sh
set -e
. ../../nvm.sh
VERSION=v0.10.26
# Remove the stuff we're clobbering.
[ -e ../../$VERSION ] && rm -R ../../$VERSION
# Install from binary
nvm install $VERSION
# Check
[ -d ../../$VERSION ]
nvm run $VERSION --version | grep $VERSION

View File

@@ -1,16 +0,0 @@
#!/bin/sh
set -e
. ../../nvm.sh
VERSION=v0.10.26
# Remove the stuff we're clobbering.
[ -e ../../$VERSION ] && rm -R ../../$VERSION
# Install from source
nvm install -s $VERSION
# Check
[ -d ../../$VERSION ]
nvm run $VERSION --version | grep $VERSION

View File

@@ -1,23 +0,0 @@
#!/bin/sh
set -e
. ../../nvm.sh
# Remove the stuff we're clobbering.
[ -e ../../v0.10.25 ] && rm -R ../../v0.10.25
[ -e ../../v0.10.26 ] && rm -R ../../v0.10.26
# Install from binary
nvm install 0.10.25
nvm install 0.10.26
# Check
[ -d ../../v0.10.25 ]
[ -d ../../v0.10.26 ]
# Use the first one
nvm use 0.10.25
# Use the latest one
nvm use 0.10
node --version | grep v0.10.26

View File

@@ -0,0 +1,17 @@
#!/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
nvm install $NVM_TEST_VERSION
# Check
[ -d ../../../$NVM_TEST_VERSION ]
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION

View File

@@ -0,0 +1,17 @@
#!/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 source
nvm install -s $NVM_TEST_VERSION
# Check
[ -d ../../../$NVM_TEST_VERSION ]
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION

View File

@@ -0,0 +1,24 @@
#!/bin/sh
set -e
. ../../../nvm.sh
# Remove the stuff we're clobbering.
[ -e ../../../v0.9.7 ] && rm -R ../../../v0.9.7
[ -e ../../../v0.9.12 ] && rm -R ../../../v0.9.12
# Install from binary
nvm install 0.9.7
nvm install 0.9.12
# Check
[ -d ../../../v0.9.7 ]
[ -d ../../../v0.9.12 ]
# Use the first one
nvm use 0.9.7
# Use the latest one
nvm use 0.9
node --version | grep v0.9.12

View File

@@ -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

View File

@@ -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

View File

@@ -0,0 +1,6 @@
#!/bin/sh
if [ -f ".nvmrc" ]; then
mv .nvmrc .nvmrc.bak
fi

View File

@@ -0,0 +1,13 @@
#!/bin/sh
. ../../../nvm.sh
nvm uninstall v0.10.7
if [ -f ".nvmrc" ]; then
rm .nvmrc
fi
if [ -f ".nvmrc.bak" ]; then
mv .nvmrc.bak .nvmrc
fi

View 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"

View 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
View 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
View 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