mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-09-02 02:34:43 +00:00
Compare commits
50 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
7a423b7bb4 | ||
![]() |
a3de7f3222 | ||
![]() |
55d892adc8 | ||
![]() |
3b42df8d1d | ||
![]() |
21fa84225c | ||
![]() |
4895aebf0a | ||
![]() |
8a29122d0a | ||
![]() |
26ed7a003a | ||
![]() |
00ca5288b0 | ||
![]() |
6d2912a2ab | ||
![]() |
1d61584402 | ||
![]() |
f6974744cd | ||
![]() |
7171cbed6f | ||
![]() |
8f66273922 | ||
![]() |
1a9ab82e24 | ||
![]() |
3fa004293c | ||
![]() |
83efa2288d | ||
![]() |
4cfe62d3d1 | ||
![]() |
802f064178 | ||
![]() |
c49cb68575 | ||
![]() |
0534872e0f | ||
![]() |
f1b8cf8fd6 | ||
![]() |
78ff9a2215 | ||
![]() |
b952be6f56 | ||
![]() |
638ae5c6fa | ||
![]() |
a7b6495172 | ||
![]() |
703e43cc2b | ||
![]() |
03636878d1 | ||
![]() |
2ee4b6f414 | ||
![]() |
10305f0791 | ||
![]() |
276c031c60 | ||
![]() |
63f72b37df | ||
![]() |
cf5bfecec4 | ||
![]() |
77c3f20956 | ||
![]() |
e4ada9fa43 | ||
![]() |
a0de15d0f7 | ||
![]() |
df4689fbd2 | ||
![]() |
018e47bec0 | ||
![]() |
74cc1eb022 | ||
![]() |
eda8ffbcc4 | ||
![]() |
b9383c9016 | ||
![]() |
25c0be1e20 | ||
![]() |
a8233eb68c | ||
![]() |
ea198c9a19 | ||
![]() |
e0537ce3df | ||
![]() |
cce5df35ba | ||
![]() |
7e269961c3 | ||
![]() |
f214ffaf1f | ||
![]() |
d016fe010a | ||
![]() |
fb5a51b1b7 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -11,4 +11,4 @@ test/bak
|
||||
node_modules/
|
||||
|
||||
.DS_Store
|
||||
|
||||
current
|
||||
|
13
Makefile
13
Makefile
@@ -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)"
|
||||
|
||||
|
@@ -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
|
||||
|
||||
|
66
install.sh
66
install.sh
@@ -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
71
nvm.sh
@@ -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
|
||||
|
@@ -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"
|
||||
|
@@ -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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ../../nvm.sh
|
||||
. ../../../nvm.sh
|
||||
|
||||
nvm ls nonexistent_version
|
||||
[ "$?" = "3" ]
|
@@ -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
|
||||
|
||||
|
11
test/fast/Listing versions/teardown
Normal file
11
test/fast/Listing versions/teardown
Normal 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
|
||||
|
32
test/fast/Running "nvm use x" should create and change the "current" symlink
Executable file
32
test/fast/Running "nvm use x" should create and change the "current" symlink
Executable 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
|
29
test/fast/Unit tests/nvm_has_system_node
Executable file
29
test/fast/Unit tests/nvm_has_system_node
Executable 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
|
||||
|
Reference in New Issue
Block a user