Compare commits

...

50 Commits

Author SHA1 Message Date
Jordan Harband
7a423b7bb4 v0.11.1 2014-07-18 01:48:46 -07:00
Jordan Harband
a3de7f3222 Fixing make release - amending a tagged commit makes the commit not match the tag. 2014-07-17 00:25:14 -07:00
Jordan Harband
55d892adc8 Fix #476 by making sure to cd into $NVM_DIR before checking out the tag. Also delete the master branch, because we won't be needing that. 2014-07-17 00:20:33 -07:00
Jordan Harband
3b42df8d1d Merge pull request #474 from mzgol/wget-hotfix
Hotfix: correctly map curl's `-C -` to wget
2014-07-16 10:16:18 -07:00
Michał Gołębiowski
21fa84225c Hotfix: correctly map curl's -C - to wget
wget doesn't need or accept the `-` parameter to `-c`. This incorrect
mapping causes `nvm install` to fail on a curlless OS.
2014-07-16 11:00:56 +02:00
Jordan Harband
4895aebf0a v0.11.0 2014-07-15 10:52:30 -07:00
Jordan Harband
8a29122d0a Adding teardown to test/fast/Listing versions/ 2014-07-15 02:01:01 -07:00
Jordan Harband
26ed7a003a Making sure to quote this output, so that paths with spaces don't break the method.
Although tests were passing in Travis for #470, they were failing locally - now they pass in both.
2014-07-15 02:00:48 -07:00
Jordan Harband
00ca5288b0 Merge pull request #470 from creationix/has_system_node
Adding nvm_has_system_node
2014-07-15 00:03:25 -07:00
Jordan Harband
6d2912a2ab Adding nvm_has_system_node 2014-07-14 21:41:26 -07:00
Jordan Harband
1d61584402 Making sure this test cleans up after itself. 2014-07-14 20:43:51 -07:00
Jordan Harband
f6974744cd Moving this nvm ls test inside the "listing versions" test subdir. 2014-07-14 12:36:28 -07:00
Jordan Harband
7171cbed6f Add an nvm_ls_current function. 2014-07-14 11:29:24 -07:00
Jordan Harband
8f66273922 Merge pull request #467 from jsdevel/adding-current-symlink
Adding a symlink in .nvm to the current version.

Fixes #430. Closes #447. Relates to #358. Fixes #355. Closes #313. Fixes #381.
2014-07-13 11:23:27 -07:00
Jordan Harband
1a9ab82e24 Merge pull request #466 from creationix/nvm_ls_minor_versions
nvm_ls minor versions
2014-07-13 11:01:12 -07:00
jsdevel
3fa004293c Adding a symlink in .nvm to the current version. 2014-07-12 12:01:35 -07:00
Jordan Harband
83efa2288d Use [0-9] instead of [[:digit:]] per https://github.com/creationix/nvm/pull/466#discussion_r14853668 - it's simpler (and probably more portable). 2014-07-12 11:02:42 -07:00
Jordan Harband
4cfe62d3d1 Fixing nvm ls 0.x to only include 0.x.* instead of 0.x*.* 2014-07-12 11:02:42 -07:00
Jordan Harband
802f064178 Adding a failing test. 2014-07-12 11:02:14 -07:00
Jordan Harband
c49cb68575 Merge pull request #468 from egilkh/master
Should escape grep in nvm_ls
2014-07-12 11:02:09 -07:00
egilkh
0534872e0f Should escape grep in nvm_ls 2014-07-12 19:33:28 +02:00
Olivier Mengué
f1b8cf8fd6 Use 'read' built-in instead of $(cat ... | head -n1) 2014-07-10 12:15:27 -07:00
Jordan Harband
78ff9a2215 Merge pull request #464 from koenpunt/release-task
add makefile release task
2014-07-10 12:14:23 -07:00
Koen Punt
b952be6f56 add makefile release task 2014-07-10 13:28:26 +02:00
Jordan Harband
638ae5c6fa Hardcode latest version number into the install script.
Fixes #462.
2014-07-10 01:24:12 -07:00
Jordan Harband
a7b6495172 Removing unnecessary line, per #461 2014-07-10 01:24:12 -07:00
Jordan Harband
703e43cc2b Merge pull request #463 from mzgol/bash
Use bash, not sh for install scritps - followup to #450
2014-07-10 01:22:39 -07:00
Michał Gołębiowski
03636878d1 Use bash, not sh for install scritps - followup to #450 2014-07-10 10:21:03 +02:00
Jordan Harband
2ee4b6f414 Correcting nvm.sh comment wrt bash 2014-07-09 18:30:52 -07:00
Jordan Harband
10305f0791 Merge pull request #460 from koenpunt/patch-1
Finalize fix for #458
2014-07-08 10:26:24 -07:00
Koen Punt
276c031c60 Finalize fix for #458 2014-07-08 14:49:24 +02:00
Jordan Harband
63f72b37df Followup per https://github.com/creationix/nvm/pull/452#issuecomment-48151847 2014-07-07 15:40:59 -07:00
Jordan Harband
cf5bfecec4 Merge pull request #452 from creationix/curl_wget_handling
Better combo curl/wget handling
2014-07-07 15:03:31 -07:00
Jordan Harband
77c3f20956 Merge pull request #459 from koenpunt/curl_wget_handling
fix nvm_curl arguments for stdout
2014-07-07 14:28:37 -07:00
Jordan Harband
e4ada9fa43 Revert part of the change from e0537ce3df, fixes #458 2014-07-07 14:22:49 -07:00
Koen Punt
a0de15d0f7 fix nvm_curl arguments for stdout 2014-07-07 23:16:20 +02:00
Jordan Harband
df4689fbd2 Removing an extra "echo" 2014-07-07 13:59:58 -07:00
Jordan Harband
018e47bec0 Make sure both wget and curl work. 2014-07-07 13:32:10 -07:00
Jordan Harband
74cc1eb022 Make nvm_curl do a runtime check if curl is available. 2014-07-07 13:32:10 -07:00
Jordan Harband
eda8ffbcc4 Add some more curl → wget argument munging 2014-07-07 13:32:10 -07:00
Jordan Harband
b9383c9016 Use nvm_curl instead of curl directly, which has a wget fallback. 2014-07-07 13:32:10 -07:00
Jordan Harband
25c0be1e20 Using an nvm_curl function instead of curl/wget directly. 2014-07-07 13:32:10 -07:00
Jordan Harband
a8233eb68c Merge pull request #457 from koenpunt/patch-1
Add newline to printf command
2014-07-07 13:02:23 -07:00
Koen Punt
ea198c9a19 add newline to printf 2014-07-07 14:43:02 +02:00
Jordan Harband
e0537ce3df Shellcheck recommendations. 2014-07-05 13:48:23 -07:00
Jordan Harband
cce5df35ba Naming install.sh functions more explicitly as being for nvm. 2014-07-05 13:44:00 -07:00
Jordan Harband
7e269961c3 In install.sh, rename has to nvm_has for consistency with nvm.sh. 2014-07-05 13:42:44 -07:00
Jordan Harband
f214ffaf1f Oxford comma 2014-07-05 11:07:14 -07:00
Jordan Harband
d016fe010a Merge pull request #450 from mzgol/install-script
Use bash, not sh for install scritps
2014-07-03 00:50:31 -07:00
Michał Gołębiowski
fb5a51b1b7 Use bash, not sh for install scritps
Install scripts don't work in pure sh; they may work on some systems where
the /bin/sh binary actually implements more than the pure Bourne Shell but
fail on other ones (e.g. Ubuntu).

Just using bash works.
2014-07-02 14:58:56 +02:00
12 changed files with 211 additions and 65 deletions

2
.gitignore vendored
View File

@@ -11,4 +11,4 @@ test/bak
node_modules/
.DS_Store
current

View File

@@ -2,7 +2,7 @@ URCHIN=`which urchin`
SHELLS=sh bash dash ksh zsh
TEST_SUITE=fast
.PHONY: $(SHELLS) test
.PHONY: $(SHELLS) test verify-tag release
$(SHELLS):
@printf '\n\033[0;34m%s\033[0m\n' "Running tests in $@"
@@ -13,3 +13,14 @@ test: $(SHELLS)
default: test
verify-tag:
ifndef TAG
$(error TAG is undefined)
endif
release: verify-tag
@ OLD_TAG=`git describe --abbrev=0 --tags` && \
replace "$${OLD_TAG/v/}" "$(TAG)" -- nvm.sh install.sh README.markdown && \
git commit -m "v$(TAG)" nvm.sh install.sh README.markdown package.json && \
git tag "v$(TAG)"

View File

@@ -8,17 +8,17 @@ First you'll need to make sure your system has a c++ compiler. For OSX, XCode w
To install you could use the [install script][2] using cURL:
curl https://raw.githubusercontent.com/creationix/nvm/v0.10.0/install.sh | sh
curl https://raw.githubusercontent.com/creationix/nvm/v0.11.1/install.sh | bash
or Wget:
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.10.0/install.sh | sh
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.11.1/install.sh | bash
<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 `PROFILE` variables. Eg: `curl ... | NVM_DIR=/usr/local/nvm sh` for a global install.
You can customize the install source, directory and profile using the `NVM_SOURCE`, `NVM_DIR` and `PROFILE` variables. Eg: `curl ... | NVM_DIR=/usr/local/nvm bash` for a global install.
<sub>*NB. The installer can use Git, cURL or Wget to download NVM, whatever is available.*</sub>
<sub>*NB. The installer can use Git, curl, or wget to download NVM, whatever is available.*</sub>
### Manual install
@@ -163,7 +163,7 @@ After the v0.8.6 release of node, nvm tries to install from binary packages. But
nvm install -s 0.8.6
[1]: https://github.com/creationix/nvm.git
[2]: https://github.com/creationix/nvm/blob/v0.10.0/install.sh
[2]: https://github.com/creationix/nvm/blob/v0.11.1/install.sh
[3]: https://travis-ci.org/creationix/nvm
[Urchin]: https://github.com/scraperwiki/urchin

View File

@@ -2,7 +2,7 @@
set -e
has() {
nvm_has() {
type "$1" > /dev/null 2>&1
return $?
}
@@ -11,19 +11,23 @@ if [ -z "$NVM_DIR" ]; then
NVM_DIR="$HOME/.nvm"
fi
if ! has "curl"; then
if has "wget"; then
nvm_download() {
if nvm_has "curl"; then
curl $*
elif nvm_has "wget"; then
# Emulate curl with wget
curl() {
ARGS="$* "
ARGS=${ARGS/-s /-q }
ARGS=${ARGS/-o /-O }
wget $ARGS
}
ARGS="$*"
ARGS=${ARGS/--progress-bar /--progress=bar }
ARGS=${ARGS/-L /}
ARGS=${ARGS/-I /}
ARGS=${ARGS/-s /-q }
ARGS=${ARGS/-o /-O }
ARGS=${ARGS/-C - /-c }
wget $ARGS
fi
fi
}
install_from_git() {
install_nvm_from_git() {
if [ -z "$NVM_SOURCE" ]; then
NVM_SOURCE="https://github.com/creationix/nvm.git"
fi
@@ -31,9 +35,9 @@ install_from_git() {
if [ -d "$NVM_DIR/.git" ]; then
echo "=> nvm is already installed in $NVM_DIR, trying to update"
printf "\r=> "
cd "$NVM_DIR" && git pull 2> /dev/null || {
echo >&2 "Failed to update nvm, run 'git pull' in $NVM_DIR yourself.."
}
cd "$NVM_DIR" && (git fetch 2> /dev/null || {
echo >&2 "Failed to update nvm, run 'git fetch' in $NVM_DIR yourself." && exit 1
})
else
# Cloning to $NVM_DIR
echo "=> Downloading nvm from git to '$NVM_DIR'"
@@ -41,11 +45,12 @@ install_from_git() {
mkdir -p "$NVM_DIR"
git clone "$NVM_SOURCE" "$NVM_DIR"
fi
cd $NVM_DIR && git checkout v0.11.1 && git branch -D master
}
install_as_script() {
install_nvm_as_script() {
if [ -z "$NVM_SOURCE" ]; then
NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/master/nvm.sh"
NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/v0.11.1/nvm.sh"
fi
# Downloading to $NVM_DIR
@@ -55,7 +60,7 @@ install_as_script() {
else
echo "=> Downloading nvm as script to '$NVM_DIR'"
fi
curl -s "$NVM_SOURCE" -o "$NVM_DIR/nvm.sh" || {
nvm_download -s "$NVM_SOURCE" -o "$NVM_DIR/nvm.sh" || {
echo >&2 "Failed to download '$NVM_SOURCE'.."
return 1
}
@@ -63,28 +68,28 @@ install_as_script() {
if [ -z "$METHOD" ]; then
# Autodetect install method
if has "git"; then
install_from_git
elif has "curl"; then
install_as_script
if nvm_has "git"; then
install_nvm_from_git
elif nvm_has "nvm_download"; then
install_nvm_as_script
else
echo >&2 "You need git, curl or wget to install nvm"
echo >&2 "You need git, curl, or wget to install nvm"
exit 1
fi
else
if [ "$METHOD" = "git" ]; then
if ! has "git"; then
if ! nvm_has "git"; then
echo >&2 "You need git to install nvm"
exit 1
fi
install_from_git
install_nvm_from_git
fi
if [ "$METHOD" = "script" ]; then
if ! has "curl"; then
if ! nvm_has "nvm_download"; then
echo >&2 "You need curl or wget to install nvm"
exit 1
fi
install_as_script
install_nvm_as_script
fi
fi
@@ -104,8 +109,8 @@ fi
SOURCE_STR="\nexport NVM_DIR=\"$NVM_DIR\"\n[ -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 ~/.bash_profile ~/.zshrc and ~/.profile."
if [ -z "$PROFILE" ]; then
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"
@@ -116,13 +121,12 @@ if [ -z "$PROFILE" ] || [ ! -f "$PROFILE" ] ; then
printf "$SOURCE_STR"
echo
else
if ! grep -qc 'nvm.sh' $PROFILE; then
if ! grep -qc 'nvm.sh' "$PROFILE"; then
echo "=> Appending source string to $PROFILE"
printf "$SOURCE_STR" >> "$PROFILE"
printf "$SOURCE_STR\n" >> "$PROFILE"
else
echo "=> Source string already in $PROFILE"
fi
fi
echo "=> Close and reopen your terminal to start using nvm"

71
nvm.sh
View File

@@ -1,5 +1,6 @@
# Node Version Manager
# Implemented as a bash function
# Implemented as a POSIX-compliant function
# Should work on sh, dash, bash, ksh, zsh
# To use source this file from your bash profile
#
# Implemented by Tim Caswell <tim@creationix.com>
@@ -9,7 +10,26 @@ NVM_SCRIPT_SOURCE="$_"
nvm_has() {
type "$1" > /dev/null 2>&1
return $?
}
nvm_download() {
if nvm_has "curl"; then
curl $*
elif nvm_has "wget"; then
# Emulate curl with wget
ARGS="$*"
ARGS=${ARGS/--progress-bar /--progress=bar }
ARGS=${ARGS/-L /}
ARGS=${ARGS/-I /}
ARGS=${ARGS/-s /-q }
ARGS=${ARGS/-o /-O }
ARGS=${ARGS/-C - /-c }
wget $ARGS
fi
}
nvm_has_system_node() {
[ "$(nvm deactivate 2> /dev/null && command -v node)" != '' ]
}
# Make zsh glob matching behave same as bash
@@ -58,7 +78,7 @@ nvm_rc_version() {
local NVMRC_PATH
NVMRC_PATH="$(nvm_find_nvmrc)"
if [ -e "$NVMRC_PATH" ]; then
NVM_RC_VERSION=`cat "$NVMRC_PATH" | head -n 1`
read NVM_RC_VERSION < "$NVMRC_PATH"
echo "Found '$NVMRC_PATH' with version <$NVM_RC_VERSION>"
fi
}
@@ -122,13 +142,17 @@ nvm_binary_available() {
[ $(nvm_normalize_version $VERSION) -ge $(nvm_normalize_version $MINIMAL) ]
}
nvm_ls_current() {
echo `node -v 2>/dev/null`
}
nvm_ls() {
local PATTERN
PATTERN=$1
local VERSIONS
VERSIONS=''
if [ "$PATTERN" = 'current' ]; then
echo `node -v 2>/dev/null`
nvm_ls_current
return
fi
@@ -137,13 +161,17 @@ nvm_ls() {
return
fi
# If it looks like an explicit version, don't do anything funny
if [ `expr "$PATTERN" : "v[[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*$"` != 0 ]; then
if [ `expr "$PATTERN" : "v[0-9]*\.[0-9]*\.[0-9]*$"` != 0 ]; then
if [ -d "$NVM_DIR/$PATTERN" ]; then
VERSIONS="$PATTERN"
fi
else
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 | grep -v '^ *\.'`
PATTERN=$(nvm_format_version $PATTERN)
if [ `expr "$PATTERN" : "v[0-9]*\.[0-9]*$"` != 0 ]; then
PATTERN="$PATTERN."
fi
VERSIONS=`find "$NVM_DIR/" -maxdepth 1 -type d -name "$PATTERN*" -exec basename '{}' ';' \
| sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n | \grep -v '^ *\.'`
fi
if [ -z "$VERSIONS" ]; then
echo "N/A"
@@ -164,7 +192,7 @@ nvm_ls_remote() {
else
PATTERN=".*"
fi
VERSIONS=`curl -s $NVM_NODEJS_ORG_MIRROR/ \
VERSIONS=`nvm_download -s $NVM_NODEJS_ORG_MIRROR/ -o - \
| \egrep -o 'v[0-9]+\.[0-9]+\.[0-9]+' \
| \grep -w "${PATTERN}" \
| sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n`
@@ -200,7 +228,7 @@ nvm_print_versions() {
local VERSION
local FORMAT
local NVM_CURRENT
NVM_CURRENT=`nvm_version current`
NVM_CURRENT=$(nvm_ls_current)
echo "$1" | while read VERSION; do
if [ "$VERSION" = "$NVM_CURRENT" ]; then
FORMAT='\033[0;32m-> %9s\033[0m'
@@ -274,7 +302,7 @@ nvm() {
echo " nvm alias default 0.10.24 Set default node version on a shell"
echo
echo "Note:"
echo " to remove, delete or uninstall nvm - just remove ~/.nvm, ~/.npm and ~/.bower folders"
echo " to remove, delete, or uninstall nvm - just remove ~/.nvm, ~/.npm, and ~/.bower folders"
echo
;;
@@ -290,8 +318,8 @@ nvm() {
version_not_provided=0
local provided_version
if ! nvm_has "curl"; then
echo 'NVM Needs curl to proceed.' >&2;
if ! nvm_has "nvm_download"; then
echo 'nvm needs curl or wget to proceed.' >&2;
return 1
fi
@@ -354,14 +382,14 @@ nvm() {
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}'`
sum=`nvm_download -s $NVM_NODEJS_ORG_MIRROR/$VERSION/SHASUMS.txt -o - | \grep node-${t}.tar.gz | awk '{print $1}'`
local tmpdir
tmpdir="$NVM_DIR/bin/node-${t}"
local tmptarball
tmptarball="$tmpdir/node-${t}.tar.gz"
if (
mkdir -p "$tmpdir" && \
curl -L -C - --progress-bar $url -o "$tmptarball" && \
nvm_download -L -C - --progress-bar $url -o "$tmptarball" && \
nvm_checksum "$tmptarball" $sum && \
tar -xzf "$tmptarball" -C "$tmpdir" --strip-components 1 && \
rm -f "$tmptarball" && \
@@ -391,16 +419,16 @@ nvm() {
tmpdir="$NVM_DIR/src"
local tmptarball
tmptarball="$tmpdir/node-$VERSION.tar.gz"
if [ "`curl -Is "$NVM_NODEJS_ORG_MIRROR/$VERSION/node-$VERSION.tar.gz" | \grep '200 OK'`" != '' ]; then
if [ "`nvm_download -s -I "$NVM_NODEJS_ORG_MIRROR/$VERSION/node-$VERSION.tar.gz" -o - | \grep '200 OK'`" != '' ]; then
tarball="$NVM_NODEJS_ORG_MIRROR/$VERSION/node-$VERSION.tar.gz"
sum=`curl -s $NVM_NODEJS_ORG_MIRROR/$VERSION/SHASUMS.txt | \grep node-$VERSION.tar.gz | awk '{print $1}'`
elif [ "`curl -Is "$NVM_NODEJS_ORG_MIRROR/node-$VERSION.tar.gz" | \grep '200 OK'`" != '' ]; then
sum=`nvm_download -s $NVM_NODEJS_ORG_MIRROR/$VERSION/SHASUMS.txt -o - | \grep node-$VERSION.tar.gz | awk '{print $1}'`
elif [ "`nvm_download -s -I "$NVM_NODEJS_ORG_MIRROR/node-$VERSION.tar.gz" -o - | \grep '200 OK'`" != '' ]; then
tarball="$NVM_NODEJS_ORG_MIRROR/node-$VERSION.tar.gz"
fi
if (
[ -n "$tarball" ] && \
mkdir -p "$tmpdir" && \
curl -L --progress-bar $tarball -o "$tmptarball" && \
nvm_download -L --progress-bar $tarball -o "$tmptarball" && \
nvm_checksum "$tmptarball" $sum && \
tar -xzf "$tmptarball" -C "$tmpdir" && \
cd "$tmpdir/node-$VERSION" && \
@@ -419,10 +447,10 @@ nvm() {
if [ "`expr "$VERSION" : '\(^v0\.2\.[0-2]$\)'`" != '' ]; then
echo "npm requires node v0.2.3 or higher" >&2
else
curl https://npmjs.org/install.sh | clean=yes npm_install=0.2.19 sh
nvm_download https://npmjs.org/install.sh -o - | clean=yes npm_install=0.2.19 sh
fi
else
curl https://npmjs.org/install.sh | clean=yes sh
nvm_download https://npmjs.org/install.sh -o - | clean=yes sh
fi
fi
else
@@ -526,6 +554,7 @@ nvm() {
export NODE_PATH
export NVM_PATH="$NVM_DIR/$VERSION/lib/node"
export NVM_BIN="$NVM_DIR/$VERSION/bin"
rm -f "$NVM_DIR/current" && ln -s "$NVM_DIR/$VERSION" "$NVM_DIR/current"
echo "Now using node $VERSION"
;;
"run" )
@@ -654,7 +683,7 @@ nvm() {
nvm_version $2
;;
"--version" )
echo "0.10.0"
echo "0.11.1"
;;
"unload" )
unset -f nvm nvm_print_versions nvm_checksum nvm_ls_remote nvm_ls nvm_remote_version nvm_version nvm_rc_version > /dev/null 2>&1

View File

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

View File

@@ -2,11 +2,40 @@
mkdir ../../../v0.1.3
mkdir ../../../v0.2.3
mkdir ../../../v0.20.3
. ../../../nvm.sh
die () { echo $@ ; exit 1; }
# 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 v0.1.3 &&
nvm ls v0.2 | grep v0.2.3
nvm ls 0.1 | grep 'v0.2.3' > /dev/null
if [ $? -eq 0 ]; then
echo '"nvm ls 0.1" contained v0.2.3'
fi
nvm ls 0.1 | grep 'v0.20.3' > /dev/null
if [ $? -eq 0 ]; then
die '"nvm ls 0.1" contained v0.20.3'
fi
nvm ls 0.1 | grep 'v0.1.3' > /dev/null
if [ $? -ne 0 ]; then
die '"nvm ls 0.1" did not contain v0.1.3'
fi
nvm ls 0.2 | grep 'v0.2.3' > /dev/null
if [ $? -ne 0 ]; then
die '"nvm ls 0.2" did not contain v0.2.3'
fi
nvm ls 0.2 | grep 'v0.20.3' > /dev/null
if [ $? -eq 0 ]; then
die '"nvm ls 0.2" contained v0.20.3'
fi
nvm ls 0.2 | grep 'v0.2.3' > /dev/null
if [ $? -ne 0 ]; then
die '"nvm ls 0.2" did not contain v0.2.3'
fi

View File

@@ -8,3 +8,4 @@ nvm ls v0.1 | grep v0.1.2 &&
nvm ls v0.1.2 | grep v0.1.2 &&
nvm ls v0.1. | grep N/A &&
nvm ls v0.1.1 | grep N/A

View File

@@ -0,0 +1,11 @@
rmdir ../../../v0.0.1
rmdir ../../../v0.0.3
rmdir ../../../v0.0.9
rmdir ../../../v0.1.2
rmdir ../../../v0.1.3
rmdir ../../../v0.2.3
rmdir ../../../v0.3.1
rmdir ../../../v0.3.3
rmdir ../../../v0.3.9
unalias nvm_has_system_node

View File

@@ -0,0 +1,32 @@
#!/bin/bash
. ../../nvm.sh
rm -rf ../../v0.10.29
mkdir ../../v0.10.29
nvm use 0.10.29
rmdir ../../v0.10.29
if [ ! -L ../../current ];then
echo "Expected 'current' symlink to be created!"
exit 1
fi
oldLink="$(readlink ../../current)"
if [ "$(basename $oldLink)" != 'v0.10.29' ];then
echo "Expected 'current' to point to v0.10.29 but was $oldLink"
exit 1
fi
rm -rf ../../v0.11.13
mkdir ../../v0.11.13
nvm use 0.11.13
rmdir ../../v0.11.13
newLink="$(readlink ../../current)"
if [ "$(basename $newLink)" != 'v0.11.13' ];then
echo "Expected 'current' to point to v0.11.13 but was $newLink"
exit 1
fi

View File

@@ -0,0 +1,29 @@
#!/bin/sh
cleanup () {
rm ../../../v0.1.2/node
rmdir ../../../v0.1.2
}
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
mkdir ../../../v0.1.2
touch ../../../v0.1.2/node
nvm use 0.1.2
if command -v node; then
nvm_has_system_node
else
! nvm_has_system_node
fi
nvm deactivate /dev/null 2>&1
if command -v node; then
nvm_has_system_node
else
! nvm_has_system_node
fi