Merge pull request #616 from ljharb/iojs

Add `io.js` support.

This branch adds support for https://github.com/iojs/io.js / https://iojs.org/

The following features should now work:
 - `nvm install iojs` will install the latest `io.js` version. `nvm ls iojs` and `nvm use iojs` will function as you'd expect.
 - `nvm install node` will install the latest stable `node` version. `nvm ls node` and `nvm use node` will function as you'd expect.
 - In general, a specific `io.js` version can be referenced with the "iojs-" prefix. If `node` were to ever release a `v1.0.0`, `v1.0.0` would refer to `node`, and `iojs-v1.0.0` would refer to `io.js`. In the near future, `node-v1.0.0` will also refer to `node` unambiguously. This applies to all `nvm` commands, including working with aliases and `.nvmrc` files.
 - `io.js`, unlike `node`, does not have a SunOS binary. Please open an issue on https://github.com/iojs/io.js if this is actually a problem for anyone, as currently it seems like this won't be for anybody.

**Note**: checksum support upon installation is currently disabled. Relates to https://github.com/iojs/io.js/issues/368.
**Note**: installation of `io.js` directly from source (via the `-s` option) is not yet enabled. This will be added soon.

Relates to https://github.com/iojs/io.js/issues/40 https://github.com/iojs/io.js/issues/420
Fixes #590
master
Jordan Harband 2015-01-19 22:14:46 -08:00
commit 879dda6c3d
28 changed files with 772 additions and 81 deletions

412
nvm.sh
View File

@ -49,6 +49,10 @@ nvm_has_system_node() {
[ "$(nvm deactivate >/dev/null 2>&1 && command -v node)" != '' ]
}
nvm_has_system_iojs() {
[ "$(nvm deactivate >/dev/null 2>&1 && command -v iojs)" != '' ]
}
# Make zsh glob matching behave same as bash
# This fixes the "zsh: no matches found" errors
if nvm_has "unsetopt"; then
@ -71,6 +75,13 @@ if [ -z "$NVM_NODEJS_ORG_MIRROR" ]; then
export NVM_NODEJS_ORG_MIRROR="https://nodejs.org/dist"
fi
if [ -z "$NVM_IOJS_ORG_MIRROR" ]; then
export NVM_IOJS_ORG_MIRROR="https://iojs.org/dist"
fi
if [ -z "$NVM_IOJS_ORG_VERSION_LISTING" ]; then
export NVM_IOJS_ORG_VERSION_LISTING="$NVM_IOJS_ORG_MIRROR/index.tab"
fi
nvm_tree_contains_path() {
local tree
tree="$1"
@ -144,6 +155,8 @@ nvm_version_dir() {
NVM_WHICH_DIR="$1"
if [ -z "$NVM_WHICH_DIR" ] || [ "_$NVM_WHICH_DIR" = "_new" ]; then
echo "$NVM_DIR/versions/node"
elif [ "_$NVM_WHICH_DIR" = "_iojs" ]; then
echo "$NVM_DIR/versions/io.js"
elif [ "_$NVM_WHICH_DIR" = "_old" ]; then
echo "$NVM_DIR"
else
@ -162,6 +175,8 @@ nvm_version_path() {
if [ -z "$VERSION" ]; then
echo "version is required" >&2
return 3
elif nvm_is_iojs_version "$VERSION"; then
echo "$(nvm_version_dir iojs)/$(nvm_strip_iojs_prefix "$VERSION")"
elif nvm_version_greater 0.12.0 "$VERSION"; then
echo "$(nvm_version_dir old)/$VERSION"
else
@ -184,11 +199,17 @@ nvm_version() {
return $?
fi
case "_$PATTERN" in
"_$(nvm_node_prefix)" | "_$(nvm_node_prefix)-")
PATTERN="stable"
;;
esac
VERSION="$(nvm_ls "$PATTERN" | tail -n1)"
if [ -z "$VERSION" ] || [ "_$VERSION" = "_N/A" ]; then
echo "N/A"
return 3;
else
echo "$VERSION"
if [ "$VERSION" = 'N/A' ]; then
return 3
fi
}
@ -196,8 +217,12 @@ nvm_remote_version() {
local PATTERN
PATTERN="$1"
local VERSION
VERSION="$(nvm_ls_remote "$PATTERN" | tail -n1)"
echo "$VERSION"
if nvm_is_iojs_version "$PATTERN"; then
VERSION="$(nvm_ls_remote_iojs "$PATTERN")"
else
VERSION="$(nvm_ls_remote "$PATTERN")"
fi
echo "$VERSION" | tail -n1
if [ "_$VERSION" = '_N/A' ]; then
return 3
@ -209,7 +234,13 @@ nvm_normalize_version() {
}
nvm_ensure_version_prefix() {
echo "$1" | command sed -e 's/^\([0-9]\)/v\1/g'
local NVM_VERSION
NVM_VERSION="$(nvm_strip_iojs_prefix "$1" | command sed -e 's/^\([0-9]\)/v\1/g')"
if nvm_is_iojs_version "$1"; then
echo "$(nvm_add_iojs_prefix "$NVM_VERSION")"
else
echo "$NVM_VERSION"
fi
}
nvm_format_version() {
@ -238,7 +269,13 @@ nvm_num_version_groups() {
}
nvm_strip_path() {
echo "$1" | command sed -e "s#$NVM_DIR/[^/]*$2[^:]*:##g" -e "s#:$NVM_DIR/[^/]*$2[^:]*##g" -e "s#$NVM_DIR/[^/]*$2[^:]*##g"
echo "$1" | command sed \
-e "s#$NVM_DIR/[^/]*$2[^:]*:##g" \
-e "s#:$NVM_DIR/[^/]*$2[^:]*##g" \
-e "s#$NVM_DIR/[^/]*$2[^:]*##g" \
-e "s#$NVM_DIR/versions/[^/]*/[^/]*$2[^:]*:##g" \
-e "s#:$NVM_DIR/versions/[^/]*/[^/]*$2[^:]*##g" \
-e "s#$NVM_DIR/versions/[^/]*/[^/]*$2[^:]*##g"
}
nvm_prepend_path() {
@ -253,7 +290,7 @@ nvm_binary_available() {
# binaries started with node 0.8.6
local FIRST_VERSION_WITH_BINARY
FIRST_VERSION_WITH_BINARY="0.8.6"
nvm_version_greater_than_or_equal_to "$1" "$FIRST_VERSION_WITH_BINARY"
nvm_version_greater_than_or_equal_to "$(nvm_strip_iojs_prefix $1)" "$FIRST_VERSION_WITH_BINARY"
}
nvm_alias() {
@ -279,9 +316,11 @@ nvm_ls_current() {
NVM_LS_CURRENT_NODE_PATH="$(command which node 2> /dev/null)"
if [ $? -ne 0 ]; then
echo 'none'
elif nvm_tree_contains_path "$(nvm_version_dir iojs)" "$NVM_LS_CURRENT_NODE_PATH"; then
echo "$(nvm_add_iojs_prefix $(iojs --version 2>/dev/null))"
elif nvm_tree_contains_path "$NVM_DIR" "$NVM_LS_CURRENT_NODE_PATH"; then
local VERSION
VERSION="$(node -v 2>/dev/null)"
VERSION="$(node --version 2>/dev/null)"
if [ "$VERSION" = "v0.6.21-pre" ]; then
echo "v0.6.21"
else
@ -345,6 +384,31 @@ nvm_resolve_alias() {
return 2
}
nvm_iojs_prefix() {
echo "iojs"
}
nvm_node_prefix() {
echo "node"
}
nvm_is_iojs_version() {
[ "_$(echo "$1" | cut -c1-5)" = "_iojs-" ]
}
nvm_add_iojs_prefix() {
command echo "$(nvm_iojs_prefix)-$(nvm_ensure_version_prefix "$(nvm_strip_iojs_prefix "$1")")"
}
nvm_strip_iojs_prefix() {
local NVM_IOJS_PREFIX
NVM_IOJS_PREFIX="$(nvm_iojs_prefix)"
if [ "_$1" = "_$NVM_IOJS_PREFIX" ]; then
echo
else
echo "$1" | command sed "s/^$NVM_IOJS_PREFIX-//"
fi
}
nvm_ls() {
local PATTERN
PATTERN="$1"
@ -359,20 +423,31 @@ nvm_ls() {
return
fi
# If it looks like an explicit version, don't do anything funny
case "$PATTERN" in
"$(nvm_iojs_prefix)" | "$(nvm_node_prefix)")
PATTERN="$PATTERN-"
;;
*)
PATTERN=$(nvm_ensure_version_prefix $PATTERN)
;;
esac
# If it looks like an explicit version, don't do anything funny
if [ "_$(echo "$PATTERN" | cut -c1-1)" = "_v" ] && [ "_$(nvm_num_version_groups "$PATTERN")" = "_3" ]; then
if [ -d "$(nvm_version_path "$PATTERN")" ]; then
VERSIONS="$PATTERN"
fi
else
if [ "_$PATTERN" != "_system" ]; then
case "$PATTERN" in
"$(nvm_iojs_prefix)-" | "$(nvm_node_prefix)-" | "system")
;;
*)
local NUM_VERSION_GROUPS
NUM_VERSION_GROUPS="$(nvm_num_version_groups "$PATTERN")"
if [ "_$NUM_VERSION_GROUPS" = "_2" ] || [ "_$NUM_VERSION_GROUPS" = "_1" ]; then
PATTERN="$(echo "$PATTERN" | command sed -e 's/\.*$//g')."
fi
fi
;;
esac
local ZHS_HAS_SHWORDSPLIT_UNSET
ZHS_HAS_SHWORDSPLIT_UNSET=1
@ -383,7 +458,26 @@ nvm_ls() {
local NVM_DIRS_TO_TEST_AND_SEARCH
local NVM_DIRS_TO_SEARCH
local NVM_ADD_SYSTEM
NVM_ADD_SYSTEM=false
if nvm_is_iojs_version "$PATTERN"; then
NVM_DIRS_TO_TEST_AND_SEARCH="$(nvm_version_dir iojs)"
PATTERN="$(nvm_strip_iojs_prefix "$PATTERN")"
if nvm_has_system_iojs; then
NVM_ADD_SYSTEM=true
fi
elif [ "_$PATTERN" = "_$(nvm_node_prefix)-" ]; then
NVM_DIRS_TO_TEST_AND_SEARCH="$(nvm_version_dir old) $(nvm_version_dir new)"
PATTERN=''
if nvm_has_system_node; then
NVM_ADD_SYSTEM=true
fi
else
NVM_DIRS_TO_TEST_AND_SEARCH="$(nvm_version_dir old) $(nvm_version_dir new) $(nvm_version_dir iojs)"
if nvm_has_system_iojs || nvm_has_system_node; then
NVM_ADD_SYSTEM=true
fi
fi
for NVM_VERSION_DIR in $NVM_DIRS_TO_TEST_AND_SEARCH; do
if [ -d "$NVM_VERSION_DIR" ]; then
NVM_DIRS_TO_SEARCH="$NVM_VERSION_DIR $NVM_DIRS_TO_SEARCH"
@ -394,19 +488,23 @@ nvm_ls() {
PATTERN='v'
fi
VERSIONS="$(command find $NVM_DIRS_TO_SEARCH -maxdepth 1 -type d -name "$PATTERN*" \
| command sed "s#$(nvm_version_dir iojs)/#"$(nvm_iojs_prefix)"-#" \
| command sed "s#^$NVM_DIR/##" \
| command grep -v -e '^versions$' \
| command sed 's#^versions/##' \
| sed -e 's/^v/node-v/' \
| command sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n \
| sed -e 's#^\(iojs\)[-/]v#\1.v#' | sed -e 's#^\(node\)[-/]v#\1.v#' \
| command sort -t. -u -k 2.2,2n -k 3,3n -k 4,4n \
| command sort -s -t- -k1.1,1.1 \
| command sed 's/^node-//')"
| command sed 's/^\(iojs\)\./\1-/' \
| command sed 's/^node\.//')"
if [ $ZHS_HAS_SHWORDSPLIT_UNSET -eq 1 ] && nvm_has "unsetopt"; then
unsetopt shwordsplit
fi
fi
if nvm_has_system_node; then
if [ "$NVM_ADD_SYSTEM" = true ]; then
if [ -z "$PATTERN" ] || [ "_$PATTERN" = "_v" ]; then
VERSIONS="$VERSIONS$(command printf '\n%s' 'system')"
elif [ "$PATTERN" = 'system' ]; then
@ -444,7 +542,28 @@ nvm_ls_remote() {
return 3
fi
echo "$VERSIONS"
return
}
nvm_ls_remote_iojs() {
local PATTERN
PATTERN="$1"
local VERSIONS
if [ -n "$PATTERN" ]; then
PATTERN="$(nvm_ensure_version_prefix $(nvm_strip_iojs_prefix "$PATTERN"))"
else
PATTERN=".*"
fi
VERSIONS="$(nvm_download -L -s $NVM_IOJS_ORG_VERSION_LISTING -o - \
| command sed 1d \
| command sed "s/^/$(nvm_iojs_prefix)-/" \
| command cut -f1 \
| command grep -w "$PATTERN" \
| command sort)"
if [ -z "$VERSIONS" ]; then
echo "N/A"
return 3
fi
echo "$VERSIONS"
}
nvm_checksum() {
@ -473,14 +592,14 @@ nvm_print_versions() {
local NVM_CURRENT
NVM_CURRENT=$(nvm_ls_current)
echo "$1" | while read VERSION; do
if [ "$VERSION" = "$NVM_CURRENT" ]; then
FORMAT='\033[0;32m-> %9s\033[0m'
elif [ -d "$(nvm_version_path "$VERSION" 2> /dev/null)" ]; then
FORMAT='\033[0;34m%12s\033[0m'
if [ "_$VERSION" = "_$NVM_CURRENT" ]; then
FORMAT='\033[0;32m-> %12s\033[0m'
elif [ "$VERSION" = "system" ]; then
FORMAT='\033[0;33m%12s\033[0m'
FORMAT='\033[0;33m%15s\033[0m'
elif [ -d "$(nvm_version_path "$VERSION" 2> /dev/null)" ]; then
FORMAT='\033[0;34m%15s\033[0m'
else
FORMAT='%12s'
FORMAT='%15s'
fi
printf "$FORMAT\n" $VERSION
done
@ -565,12 +684,68 @@ nvm_get_arch() {
echo "$NVM_ARCH"
}
nvm_install_iojs_binary() {
local PREFIXED_VERSION
PREFIXED_VERSION="$1"
local REINSTALL_PACKAGES_FROM
REINSTALL_PACKAGES_FROM="$2"
if ! nvm_is_iojs_version "$PREFIXED_VERSION"; then
echo 'nvm_install_iojs_binary requires an iojs-prefixed version.' >&2
return 10
fi
local VERSION
VERSION="$(nvm_strip_iojs_prefix "$PREFIXED_VERSION")"
local VERSION_PATH
VERSION_PATH="$(nvm_version_path "$PREFIXED_VERSION")"
local NVM_OS
NVM_OS="$(nvm_get_os)"
local t
local url
local sum
if [ -n "$NVM_OS" ]; then
if nvm_binary_available "$VERSION"; then
t="$VERSION-$NVM_OS-$(nvm_get_arch)"
url="$NVM_IOJS_ORG_MIRROR/$VERSION/$(nvm_iojs_prefix)-${t}.tar.gz"
sum="$(nvm_download -L -s $NVM_IOJS_ORG_MIRROR/$VERSION/SHASUMS256.txt -o - | command grep $(nvm_iojs_prefix)-${t}.tar.gz | command awk '{print $1}')"
local tmpdir
tmpdir="$NVM_DIR/bin/iojs-${t}"
local tmptarball
tmptarball="$tmpdir/iojs-${t}.tar.gz"
if (
command mkdir -p "$tmpdir" && \
nvm_download -L -C - --progress-bar $url -o "$tmptarball" && \
echo "WARNING: checksums are currently disabled for io.js" >&2 && \
# nvm_checksum "$tmptarball" $sum && \
command tar -xzf "$tmptarball" -C "$tmpdir" --strip-components 1 && \
command rm -f "$tmptarball" && \
command mkdir -p "$VERSION_PATH" && \
command mv "$tmpdir"/* "$VERSION_PATH"
); then
return 0
else
echo "Binary download failed, trying source." >&2
command rm -rf "$tmptarball" "$tmpdir"
return 1
fi
fi
fi
return 2
}
nvm_install_node_binary() {
local VERSION
VERSION="$1"
local REINSTALL_PACKAGES_FROM
REINSTALL_PACKAGES_FROM="$2"
if nvm_is_iojs_version "$PREFIXED_VERSION"; then
echo 'nvm_install_node_binary does not allow an iojs-prefixed version.' >&2
return 10
fi
local VERSION_PATH
VERSION_PATH="$(nvm_version_path "$VERSION")"
local NVM_OS
@ -594,9 +769,9 @@ nvm_install_node_binary() {
nvm_checksum "$tmptarball" $sum && \
command tar -xzf "$tmptarball" -C "$tmpdir" --strip-components 1 && \
command rm -f "$tmptarball" && \
command mv "$tmpdir" "$VERSION_PATH"
)
then
command mkdir -p "$VERSION_PATH" && \
command mv "$tmpdir"/* "$VERSION_PATH"
); then
return 0
else
echo "Binary download failed, trying source." >&2
@ -768,10 +943,6 @@ nvm() {
shift
fi
if [ "_$NVM_OS" = "_freebsd" ]; then
nobinary=1
fi
provided_version="$1"
if [ -z "$provided_version" ]; then
@ -783,7 +954,18 @@ nvm() {
shift
fi
case "_$provided_version" in
"_$(nvm_iojs_prefix)" | "_io.js")
VERSION="$(nvm_add_iojs_prefix $(nvm_ls_remote_iojs | tail -n1))"
;;
"_$(nvm_node_prefix)")
VERSION="$(nvm_ls_remote stable)"
;;
*)
VERSION="$(nvm_remote_version "$provided_version")"
;;
esac
ADDITIONAL_PARAMETERS=''
local PROVIDED_REINSTALL_PACKAGES_FROM
local REINSTALL_PACKAGES_FROM
@ -810,6 +992,11 @@ nvm() {
return 5
fi
local NVM_IOJS
if nvm_is_iojs_version "$VERSION"; then
NVM_IOJS=true
fi
local VERSION_PATH
VERSION_PATH="$(nvm_version_path "$VERSION")"
if [ -d "$VERSION_PATH" ]; then
@ -825,9 +1012,24 @@ nvm() {
return 3
fi
if [ "_$NVM_OS" = "_freebsd" ]; then
# node.js and io.js do not have a FreeBSD binary
nobinary=1
elif [ "_$NVM_OS" = "_sunos" ] && [ "$NVM_IOJS" = true ]; then
# io.js does not have a SunOS binary
nobinary=1
fi
# skip binary install if "nobinary" option specified.
if [ $nobinary -ne 1 ] && nvm_install_node_binary "$VERSION" "$REINSTALL_PACKAGES_FROM"; then
if nvm use "$VERSION" \
if [ $nobinary -ne 1 ] && nvm_binary_available "$VERSION"; then
local NVM_INSTALL_SUCCESS
if [ "$NVM_IOJS" = true ] && nvm_install_iojs_binary "$VERSION" "$REINSTALL_PACKAGES_FROM"; then
NVM_INSTALL_SUCCESS=true
elif [ "$NVM_IOJS" != true ] && nvm_install_node_binary "$VERSION" "$REINSTALL_PACKAGES_FROM"; then
NVM_INSTALL_SUCCESS=true
fi
if [ "$NVM_INSTALL_SUCCESS" = true ] \
&& nvm use "$VERSION" \
&& [ ! -z "$REINSTALL_PACKAGES_FROM" ] \
&& [ "_$REINSTALL_PACKAGES_FROM" != "_N/A" ]; then
nvm reinstall-packages "$REINSTALL_PACKAGES_FROM"
@ -835,17 +1037,38 @@ nvm() {
return $?
fi
if [ "$NVM_IOJS" = true ]; then
# nvm_install_iojs_source "$VERSION" "$REINSTALL_PACKAGES_FROM" "$ADDITIONAL_PARAMETERS"
echo "Installing iojs from source is not currently supported" >&2
return 105
else
nvm_install_node_source "$VERSION" "$REINSTALL_PACKAGES_FROM" "$ADDITIONAL_PARAMETERS"
fi
;;
"uninstall" )
[ $# -ne 2 ] && nvm help && return
PATTERN="$(nvm_ensure_version_prefix "$2")"
if [ "_$PATTERN" = "_$(nvm_version)" ]; then
echo "nvm: Cannot uninstall currently-active node version, $PATTERN." >&2
local PATTERN
PATTERN="$2"
local VERSION
case "_$PATTERN" in
"_$(nvm_iojs_prefix)" | "_$(nvm_iojs_prefix)-" \
| "_$(nvm_node_prefix)" | "_$(nvm_node_prefix)-")
VERSION="$(nvm_version $PATTERN)"
;;
*)
VERSION="$(nvm_version "$PATTERN")"
;;
esac
if [ "_$PATTERN" = "_$(nvm_ls_current)" ]; then
if nvm_is_iojs_version "$PATTERN"; then
echo "nvm: Cannot uninstall currently-active io.js version, $VERSION (inferred from $PATTERN)." >&2
else
echo "nvm: Cannot uninstall currently-active node version, $VERSION (inferred from $PATTERN)." >&2
fi
return 1
fi
local VERSION
VERSION="$(nvm_version "$PATTERN")"
local VERSION_PATH
VERSION_PATH="$(nvm_version_path "$VERSION")"
if [ ! -d "$VERSION_PATH" ]; then
@ -855,20 +1078,28 @@ nvm() {
t="$VERSION-$(nvm_get_os)-$(nvm_get_arch)"
local NVM_PREFIX
local NVM_SUCCESS_MSG
if nvm_is_iojs_version "$VERSION"; then
NVM_PREFIX="$(nvm_iojs_prefix)"
NVM_SUCCESS_MSG="Uninstalled io.js $(nvm_strip_iojs_prefix $VERSION)"
else
NVM_PREFIX="$(nvm_node_prefix)"
NVM_SUCCESS_MSG="Uninstalled node $VERSION"
fi
# Delete all files related to target version.
command rm -rf "$NVM_DIR/src/node-$VERSION" \
"$NVM_DIR/src/node-$VERSION.tar.gz" \
"$NVM_DIR/bin/node-${t}" \
"$NVM_DIR/bin/node-${t}.tar.gz" \
command rm -rf "$NVM_DIR/src/$NVM_PREFIX-$VERSION" \
"$NVM_DIR/src/$NVM_PREFIX-$VERSION.tar.gz" \
"$NVM_DIR/bin/$NVM_PREFIX-${t}" \
"$NVM_DIR/bin/$NVM_PREFIX-${t}.tar.gz" \
"$VERSION_PATH" 2>/dev/null
echo "Uninstalled node $VERSION"
echo "$NVM_SUCCESS_MSG"
# Rm any aliases that point to uninstalled version.
# rm any aliases that point to uninstalled version.
for ALIAS in `command grep -l $VERSION "$(nvm_alias_path)/*" 2>/dev/null`
do
nvm unalias "$(command basename "$ALIAS")"
done
;;
"deactivate" )
local NEWPATH
@ -900,16 +1131,31 @@ nvm() {
nvm help
return 127
fi
if [ $# -eq 1 ]; then
nvm_rc_version
if [ -n "$NVM_RC_VERSION" ]; then
VERSION="$(nvm_version "$NVM_RC_VERSION")"
fi
elif [ "_$2" != '_system' ]; then
VERSION="$(nvm_version "$2")"
else
VERSION="$2"
local NVM_IOJS_PREFIX
NVM_IOJS_PREFIX="$(nvm_iojs_prefix)"
case "_$2" in
"_$NVM_IOJS_PREFIX" | "_io.js")
VERSION="$(nvm_add_iojs_prefix $(nvm_ls | command grep "$NVM_IOJS_PREFIX" | tail -n1))"
;;
"_$(nvm_node_prefix)")
VERSION="$(nvm_version stable)"
;;
"_system")
VERSION="system"
;;
*)
VERSION="$(nvm_version "$2")"
;;
esac
fi
if [ -z "$VERSION" ]; then
nvm help
return 127
@ -919,6 +1165,9 @@ nvm() {
if nvm_has_system_node && nvm deactivate >/dev/null 2>&1; then
echo "Now using system version of node: $(node -v 2>/dev/null)."
return
elif nvm_has_system_iojs && nvm deactivate >/dev/null 2>&1; then
echo "Now using system version of io.js: $(iojs --version 2>/dev/null)."
return
else
echo "System version of node not found." >&2
return 127
@ -990,11 +1239,22 @@ nvm() {
fi
fi
echo "Running node $VERSION"
local NVM_IOJS
if nvm_is_iojs_version "$VERSION"; then
NVM_IOJS=true
fi
local ARGS
ARGS="$@"
local OUTPUT
if [ "$NVM_IOJS" = true ]; then
echo "Running io.js $(nvm_strip_iojs_prefix "$VERSION")"
OUTPUT="$(nvm use "$VERSION" >/dev/null && iojs "$ARGS")"
else
echo "Running node $VERSION"
OUTPUT="$(nvm use "$VERSION" >/dev/null && node "$ARGS")"
fi
local EXIT_CODE
EXIT_CODE="$?"
echo "$OUTPUT"
@ -1037,11 +1297,44 @@ nvm() {
return $NVM_LS_EXIT_CODE
;;
"ls-remote" | "list-remote" )
local NVM_LS_EXIT_CODE
NVM_LS_OUTPUT=$(nvm_ls_remote "$2")
NVM_LS_EXIT_CODE=$?
nvm_print_versions "$NVM_LS_OUTPUT"
return $NVM_LS_EXIT_CODE
local PATTERN
PATTERN="$2"
local NVM_FLAVOR
case "_$PATTERN" in
"_$(nvm_iojs_prefix)" | "_$(nvm_node_prefix)" )
NVM_FLAVOR="$PATTERN"
PATTERN="$3"
;;
esac
local NVM_LS_REMOTE_EXIT_CODE
NVM_LS_REMOTE_EXIT_CODE=0
local NVM_LS_REMOTE_OUTPUT
NVM_LS_REMOTE_OUTPUT=''
if [ "_$NVM_FLAVOR" != "_$(nvm_iojs_prefix)" ]; then
NVM_LS_REMOTE_OUTPUT=$(nvm_ls_remote "$PATTERN")
NVM_LS_REMOTE_EXIT_CODE=$?
fi
local NVM_LS_REMOTE_IOJS_EXIT_CODE
NVM_LS_REMOTE_IOJS_EXIT_CODE=0
local NVM_LS_REMOTE_IOJS_OUTPUT
NVM_LS_REMOTE_IOJS_OUTPUT=''
if [ "_$NVM_FLAVOR" != "_$(nvm_node_prefix)" ]; then
NVM_LS_REMOTE_IOJS_OUTPUT=$(nvm_ls_remote_iojs "$PATTERN")
NVM_LS_REMOTE_IOJS_EXIT_CODE=$?
fi
local NVM_OUTPUT
NVM_OUTPUT="$(echo "$NVM_LS_REMOTE_OUTPUT
$NVM_LS_REMOTE_IOJS_OUTPUT" | grep -v "N/A" | sed '/^$/d')"
if [ -n "$NVM_OUTPUT" ]; then
nvm_print_versions "$NVM_OUTPUT"
return $NVM_LS_REMOTE_EXIT_CODE || $NVM_LS_REMOTE_IOJS_EXIT_CODE
else
nvm_print_versions "N/A"
return 3
fi
;;
"current" )
nvm_version current
@ -1063,7 +1356,7 @@ nvm() {
fi
if [ "_$VERSION" = '_system' ]; then
if nvm_has_system_node >/dev/null 2>&1; then
if nvm_has_system_iojs >/dev/null 2>&1 || nvm_has_system_node >/dev/null 2>&1; then
local NVM_BIN
NVM_BIN="$(nvm use system >/dev/null 2>&1 && command which node)"
if [ -n "$NVM_BIN" ]; then
@ -1162,8 +1455,8 @@ nvm() {
local INSTALLS
if [ "_$PROVIDED_VERSION" = "_system" ]; then
if ! nvm_has_system_node; then
echo 'No system version of node detected.' >&2
if ! nvm_has_system_node && ! nvm_has_system_iojs; then
echo 'No system version of node or io.js detected.' >&2
return 3
fi
INSTALLS=$(nvm deactivate > /dev/null && npm list -g --depth=0 | command tail -n +2 | command grep -o -e ' [^@]*' | command cut -c 2- | command grep -v npm | command xargs)
@ -1187,7 +1480,14 @@ nvm() {
echo "0.22.2"
;;
"unload" )
unset -f nvm nvm_print_versions nvm_checksum nvm_ls_remote nvm_ls nvm_remote_version nvm_version nvm_rc_version nvm_version_greater nvm_version_greater_than_or_equal_to nvm_supports_source_options > /dev/null 2>&1
unset -f nvm nvm_print_versions nvm_checksum \
nvm_iojs_prefix nvm_node_prefix \
nvm_add_iojs_prefix nvm_strip_iojs_prefix \
nvm_is_iojs_version \
nvm_ls_remote nvm_ls nvm_remote_version \
nvm_version nvm_rc_version \
nvm_version_greater nvm_version_greater_than_or_equal_to \
nvm_supports_source_options > /dev/null 2>&1
unset RC_VERSION NVM_NODEJS_ORG_MIRROR NVM_DIR NVM_CD_FLAGS > /dev/null 2>&1
;;
* )

View File

@ -8,11 +8,17 @@ mkdir ../../../v0.0.9
mkdir ../../../v0.3.1
mkdir ../../../v0.3.3
mkdir ../../../v0.3.9
mkdir -p ../../../versions/node/v0.12.87
mkdir -p ../../../versions/node/v0.12.9
mkdir -p ../../../versions/io.js/v0.1.2
mkdir -p ../../../versions/io.js/v0.10.2
# The result should contain the version numbers.
nvm ls | grep v0.0.1 &&
nvm ls | grep v0.0.3 &&
nvm ls | grep v0.0.9 &&
nvm ls | grep v0.3.1 &&
nvm ls | grep v0.3.3 &&
nvm ls | grep v0.3.9
nvm ls | grep v0.0.1 >/dev/null &&
nvm ls | grep v0.0.3 >/dev/null &&
nvm ls | grep v0.0.9 >/dev/null &&
nvm ls | grep v0.3.1 >/dev/null &&
nvm ls | grep v0.3.3 >/dev/null &&
nvm ls | grep v0.3.9 >/dev/null &&
nvm ls | grep v0.12.87 >/dev/null &&
nvm ls | grep iojs-v0.1.2 >/dev/null

View File

@ -0,0 +1,9 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
[ "_$(nvm_add_iojs_prefix 1)" = "_iojs-v1" ] || die '"nvm_add_iojs_prefix 1" did not return "iojs-v1"'
[ "_$(nvm_add_iojs_prefix iojs-1)" = "_iojs-v1" ] || die '"nvm_add_iojs_prefix iojs-1" did not return "iojs-v1"'
[ "_$(nvm_add_iojs_prefix iojs-1.2.3)" = "_iojs-v1.2.3" ] || die '"nvm_add_iojs_prefix iojs-1.2.3" did not return "iojs-v1.2.3"'

View File

@ -7,3 +7,6 @@ die () { echo $@ ; exit 1; }
[ "_$(nvm_ensure_version_prefix 1)" = "_v1" ] || die '"nvm_ensure_version_prefix 1" did not return "v1"'
[ "_$(nvm_ensure_version_prefix v1)" = "_v1" ] || die '"nvm_ensure_version_prefix v1" did not return "v1"'
[ "_$(nvm_ensure_version_prefix foo)" = "_foo" ] || die '"nvm_ensure_version_prefix foo" did not return "foo"'
[ "_$(nvm_ensure_version_prefix iojs-1)" = "_iojs-v1" ] || die '"nvm_ensure_version_prefix iojs-1" did not return "iojs-v1"'
[ "_$(nvm_ensure_version_prefix iojs-v1)" = "_iojs-v1" ] || die '"nvm_ensure_version_prefix iojs-v1" did not return "iojs-v1"'

View File

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

View File

@ -0,0 +1,7 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
[ "$(nvm_iojs_prefix)" = "iojs" ] || die '"nvm_iojs_prefix" did not return the string "iojs". why did this fail?!'

View File

@ -0,0 +1,10 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
nvm_is_iojs_version 'iojs-' || die '"nvm_is_iojs_version iojs- was not true'
nvm_is_iojs_version 'iojs-foo' || die '"nvm_is_iojs_version iojs- was not true'
! nvm_is_iojs_version 'iojs' || die '"nvm_is_iojs_version iojs was not false'
! nvm_is_iojs_version 'v1.0.0' || die '"nvm_is_iojs_version v1.0.0" was not false'

View File

@ -0,0 +1,34 @@
#!/bin/sh
die () { echo $@ ; cleanup ; exit 1; }
cleanup() {
unset -f nvm_download
}
. ../../../nvm.sh
# sample output at the time the test was written
nvm_download() {
echo 'version date files npm v8 uv zlib openssl modules'
echo 'v1.0.1 2015-01-14 linux-armv7l,linux-x64,linux-x86,osx-x64-tar,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi'
echo 'v1.0.0 2015-01-14 linux-armv7l,linux-x64,linux-x86,osx-x64-tar,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi'
}
OUTPUT="$(nvm_ls_remote_iojs foo)"
EXIT_CODE="$(nvm_ls_remote_iojs foo >/dev/null 2>&1 ; echo $?)"
[ "_$OUTPUT" = "_N/A" ] || die "nonexistent version did not report N/A"
[ "_$EXIT_CODE" = "_3" ] || die "nonexistent version did not exit with code 3, got $EXIT_CODE"
OUTPUT="$(nvm_ls_remote_iojs)"
EXPECTED_OUTPUT="$(nvm_download | \egrep -o 'v[0-9]+\.[0-9]+\.[0-9]+' | sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n | sed -e 's/^/iojs-/')"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "bare nvm_ls_remote_iojs did not output expected sorted versions; got $(echo "$OUTPUT") expected $(echo "$EXPECTED_OUTPUT")"
OUTPUT="$(nvm_ls_remote_iojs 1.0)"
EXPECTED_OUTPUT="iojs-v1.0.0
iojs-v1.0.1"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote_iojs 1.0 did not output 1.0.x versions; got $OUTPUT"
cleanup

View File

@ -0,0 +1,7 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
[ "$(nvm_node_prefix)" = "node" ] || die '"nvm_node_prefix" did not return the string "node". why did this fail?!'

View File

@ -3,7 +3,7 @@
die () { echo $@ ; cleanup ; exit 1; }
cleanup() {
unset -f nvm_ls_remote
unset -f nvm_ls_remote nvm_ls_remote_iojs
}
. ../../../nvm.sh
@ -11,25 +11,42 @@ cleanup() {
nvm_ls_remote() {
echo "N/A"
}
OUTPUT="$(nvm_remote_version foo)"
EXIT_CODE="$(nvm_remote_version foo >/dev/null 2>&1 ; echo $?)"
[ "_$OUTPUT" = "_N/A" ] || die "nonexistent version did not report N/A"
[ "_$EXIT_CODE" = "_3" ] || die "nonexistent version did not exit with code 3, got $EXIT_CODE"
nvm_ls_remote_iojs() {
echo "N/A"
}
OUTPUT="$(nvm_remote_version iojs-foo)"
EXIT_CODE="$(nvm_remote_version iojs-foo >/dev/null 2>&1 ; echo $?)"
[ "_$OUTPUT" = "_N/A" ] || die "nonexistent version did not report N/A"
[ "_$EXIT_CODE" = "_3" ] || die "nonexistent version did not exit with code 3, got $EXIT_CODE"
nvm_ls_remote() {
echo "test output"
echo "more test output"
echo "pattern received: _$1_"
}
OUTPUT="$(nvm_remote_version foo)"
EXIT_CODE="$(nvm_remote_version foo >/dev/null 2>&1 ; echo $?)"
[ "_$OUTPUT" = "_pattern received: _foo_" ] \
|| die "nvm_remote_version foo did not return last line only of nvm_ls_remote foo; got $OUTPUT"
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version foo did not exit with 0, got $EXIT_CODE"
nvm_ls_remote_iojs() {
echo "test iojs output"
echo "more iojs test output"
echo "iojs pattern received: _$1_"
}
OUTPUT="$(nvm_remote_version iojs-foo)"
EXIT_CODE="$(nvm_remote_version iojs-foo >/dev/null 2>&1 ; echo $?)"
[ "_$OUTPUT" = "_iojs pattern received: _iojs-foo_" ] \
|| die "nvm_remote_version iojs-foo did not return last line only of nvm_ls_remote_iojs foo; got $OUTPUT"
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version iojs-foo did not exit with 0, got $EXIT_CODE"
cleanup

View File

@ -0,0 +1,10 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
[ "_$(nvm_strip_iojs_prefix iojs)" = "_" ] || die '"nvm_strip_iojs_prefix iojs" did not return an empty string'
[ "_$(nvm_strip_iojs_prefix iojs-)" = "_" ] || die '"nvm_strip_iojs_prefix iojs-" did not return an empty string'
[ "_$(nvm_strip_iojs_prefix iojs-foo)" = "_foo" ] || die '"nvm_strip_iojs_prefix iojs-foo" did not return "foo"'
[ "_$(nvm_strip_iojs_prefix iojsfoo)" = "_iojsfoo" ] || die '"nvm_strip_iojs_prefix iojsfoo" did not return "iojsfoo"'

View File

@ -4,7 +4,7 @@ die () { echo $@ ; exit 1; }
. ../../../nvm.sh
TEST_PATH=$NVM_DIR/v0.10.5/bin:/usr/bin:$NVM_DIR/v0.11.5/bin:$NVM_DIR/v0.9.5/bin:/usr/local/bin:$NVM_DIR/v0.2.5/bin
TEST_PATH=$NVM_DIR/v0.10.5/bin:/usr/bin:$NVM_DIR/v0.11.5/bin:$NVM_DIR/v0.9.5/bin:/usr/local/bin:$NVM_DIR/v0.2.5/bin:$NVM_DIR/versions/node/v0.12.0/bin:$NVM_DIR/versions/io.js/v1.0.0/bin
STRIPPED_PATH=`nvm_strip_path "$TEST_PATH" "/bin"`

View File

@ -0,0 +1,48 @@
#!/bin/sh
die () { echo $@ ; cleanup ; exit 1; }
cleanup () {
unset -f nvm_ls_current nvm_ls
}
. ../../../nvm.sh
nvm_ls_current() {
echo "CURRENT!"
return 7
}
OUTPUT="$(nvm_version current)"
EXPECTED_OUTPUT="CURRENT!"
EXIT_CODE="$(nvm_version current 2>&1 >/dev/null ; echo $?)"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die '"nvm_version current" did not return nvm_ls_current output'
[ "_$EXIT_CODE" = "_7" ] || die '"nvm_version current" did not return nvm_ls_current exit code'
OUTPUT="$(nvm_version)"
EXPECTED_OUTPUT="CURRENT!"
EXIT_CODE="$(nvm_version 2>&1 >/dev/null ; echo $?)"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die '"nvm_version" did not return nvm_ls_current output'
[ "_$EXIT_CODE" = "_7" ] || die '"nvm_version" did not return nvm_ls_current exit code'
nvm_ls() {
echo "line 1"
echo "line 2"
echo "pattern: $1"
}
[ "_$(nvm_version foo)" = "_pattern: foo" ] || die '"nvm_version foo" did not pass the pattern to "nvm_ls", or return the last line'
[ "_$(nvm_version node)" = "_pattern: stable" ] || die '"nvm_version node" did not pass "stable" to "nvm_ls"'
[ "_$(nvm_version node-)" = "_pattern: stable" ] || die '"nvm_version node-" did not pass "stable" to "nvm_ls"'
nvm_ls() { echo "N/A"; }
OUTPUT="$(nvm_version foo)"
EXPECTED_OUTPUT="N/A"
EXIT_CODE="$(nvm_version foo 2>&1 >/dev/null ; echo $?)"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die '"nvm_version" did not return N/A when nvm_ls returns N/A'
[ "_$EXIT_CODE" = "_3" ] || die '"nvm_version" returning N/A did not exit code with code 3'
nvm_ls() { echo; }
OUTPUT="$(nvm_version foo)"
EXPECTED_OUTPUT="N/A"
EXIT_CODE="$(nvm_version foo 2>&1 >/dev/null ; echo $?)"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die '"nvm_version" did not return N/A when nvm_ls returns nothing'
[ "_$EXIT_CODE" = "_3" ] || die '"nvm_version" returning N/A did not exit code with code 3'

View File

@ -5,6 +5,7 @@ die () { echo $@ ; exit 1; }
. ../../../nvm.sh
[ "$(nvm_version_dir)" = "$NVM_DIR/versions/node" ] || die '"nvm_version_dir" did not return new dir path'
[ "$(nvm_version_dir iojs)" = "$NVM_DIR/versions/io.js" ] || die '"nvm_version_dir iojs" did not return iojs dir path'
[ "$(nvm_version_dir new)" = "$(nvm_version_dir)" ] || die '"nvm_version_dir new" did not return new dir path'
[ "$(nvm_version_dir old)" = "$NVM_DIR" ] || die '"nvm_version_dir old" did not return old dir path'
[ "$(nvm_version_dir foo 2>&1)" = "unknown version dir" ] || die '"nvm_version_dir foo" did not error out'

View File

@ -8,4 +8,5 @@ die () { echo $@ ; exit 1; }
[ "$(nvm_version_path 2>&1)" = "version is required" ] || die '"nvm_version_path" did not error out'
[ "$(nvm_version_path v0.11.0)" = "$NVM_DIR/v0.11.0" ] || die 'old version has the wrong path'
[ "$(nvm_version_path v0.12.0)" = "$NVM_DIR/versions/node/v0.12.0" ] || die 'new version has the wrong path'
[ "$(nvm_version_path iojs-v0.12.0)" = "$NVM_DIR/versions/io.js/v0.12.0" ] || die 'iojs version has the wrong path'

View File

@ -0,0 +1,26 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
[ "$(nvm install invalid.invalid 2>&1)" = "Version 'invalid.invalid' not found - try \`nvm ls-remote\` to browse available versions." ] || die "nvm installing an invalid version did not print a nice error message"
# Remove the stuff we're clobbering.
[ -e ../../../versions/io.js/v1.0.0 ] && rm -R ../../../versions/io.js/v1.0.0
[ -e ../../../versions/io.js/v1.0.1 ] && rm -R ../../../versions/io.js/v1.0.1
# Install from binary
nvm install iojs-v1.0.0
nvm install iojs-v1.0.1
nvm use iojs-v1.0.0
node --version | grep v1.0.0 || die "precondition failed: iojs node doesn't start at v1.0.0"
iojs --version | grep v1.0.0 || die "precondition failed: iojs binary doesn't start at v1.0.0"
nvm install iojs-v1.0.1
node --version | grep v1.0.1 || die "nvm install on already installed version doesn't use it (node binary)"
iojs --version | grep v1.0.1 || die "nvm install on already installed version doesn't use it (iojs binary)"

View File

@ -0,0 +1,19 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
NVM_TEST_VERSION="v1.0.0"
NVM_PREFIXED_TEST_VERSION="iojs-$NVM_TEST_VERSION"
# Remove the stuff we're clobbering.
[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION
# Install from binary
nvm install $NVM_PREFIXED_TEST_VERSION || die "install $NVM_PREFIXED_TEST_VERSION failed"
# Check
[ -d ../../../versions/io.js/$NVM_TEST_VERSION ]
nvm run $NVM_PREFIXED_TEST_VERSION --version | grep $NVM_TEST_VERSION || die "'nvm run $NVM_PREFIXED_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed"

View File

@ -0,0 +1,26 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
# Remove the stuff we're clobbering.
[ -e ../../../versions/io.js/v1.0.0 ] && rm -R ../../../versions/io.js/v1.0.0
[ -e ../../../versions/io.js/v1.0.1 ] && rm -R ../../../versions/io.js/v1.0.1
# Install from binary
nvm install iojs-v1.0.0 || die "'nvm install iojs-v1.0.0' failed"
nvm i iojs-v1.0.1 || die "'nvm i iojs-v1.0.1' failed"
# Check
[ -d ../../../versions/io.js/v1.0.0 ] || die "iojs v1.0.0 didn't exist"
[ -d ../../../versions/io.js/v1.0.1 ] || die "iojs v1.0.1 didn't exist"
# Use the first one
nvm use iojs-1.0.0 || die "'nvm use iojs-1.0.0' failed"
# Use the latest one
nvm use iojs-1 || die "'nvm use iojs-1' failed"
[ "_$(node --version)" = "_v1.0.1" ] || die "'node --version' was not v1.0.1, got: $(node --version)"
[ "_$(iojs --version)" = "_v1.0.1" ] || die "'iojs --version' was not v1.0.1, got: $(iojs --version)"

View File

@ -0,0 +1,24 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
NVM_TEST_VERSION=v1.0.0
NVM_PREFIXED_TEST_VERSION="iojs-$NVM_TEST_VERSION"
VERSION_PATH="../../../versions/io.js/$NVM_TEST_VERSION"
# Remove the stuff we're clobbering.
[ -e $VERSION_PATH ] && rm -R $VERSION_PATH
# Install from binary
echo "$NVM_PREFIXED_TEST_VERSION" > .nvmrc
nvm install || die "'nvm install' failed"
# Check
[ -d $VERSION_PATH ] || die "./$VERSION_PATH did not exist"
nvm run $NVM_PREFIXED_TEST_VERSION --version | grep $NVM_TEST_VERSION \
|| "'nvm run $NVM_PREFIXED_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed"

View File

@ -0,0 +1,32 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
# Remove the stuff we're clobbering.
[ -e ../../../versions/io.js/v1.0.0 ] && rm -R ../../../versions/io.js/v1.0.0
[ -e ../../../versions/io.js/v1.0.1 ] && rm -R ../../../versions/io.js/v1.0.1
# Install from binary
nvm install iojs-v1.0.0
# Check
[ -d ../../../versions/io.js/v1.0.0 ] || die "nvm install iojs-v1.0.0 didn't install"
node --version | grep v1.0.0 > /dev/null || die "nvm install didn't use iojs-v1.0.0"
npm install -g is-nan@1.0.1 || die "npm install -g is-nan failed"
npm list --global | grep is-nan > /dev/null || die "is-nan isn't installed"
nvm ls iojs-1 | grep iojs-v1.0.0 > /dev/null || die "nvm ls iojs-1 didn't show iojs-v1.0.0"
nvm install iojs-v1.0.1 --reinstall-packages-from=iojs-1.0.0 || die "nvm install iojs-v1.0.1 --reinstall-packages-from=iojs-1.0.0 failed"
[ -d ../../../versions/io.js/v1.0.1 ] || die "nvm install iojs-v1.0.1 didn't install"
nvm use iojs-1
node --version | grep v1.0.1 > /dev/null || die "nvm use iojs-1 didn't use v1.0.1"
npm list --global | grep is-nan > /dev/null || die "is-nan isn't installed"

View File

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

View File

@ -0,0 +1,14 @@
#!/bin/sh
. ../../../nvm.sh
nvm deactivate
nvm uninstall iojs-v1.0.0
if [ -f ".nvmrc" ]; then
rm .nvmrc
fi
if [ -f ".nvmrc.bak" ]; then
mv .nvmrc.bak .nvmrc
fi

View File

@ -5,6 +5,6 @@ die () { echo $@ ; exit 1; }
. ../../nvm.sh
nvm install 0.6.21 || die 'v0.6.21 installation failed'
[ "$(node -v)" = "v0.6.21-pre" ] || die "v0.6.21-pre not installed with v0.6.21, got $(node -v)"
[ "$(nvm current)" = "v0.6.21" ] || die "v0.6.21-pre not reported as v0.6.21, got $(nvm current)"
[ "_$(node -v)" = "_v0.6.21-pre" ] || die "v0.6.21-pre not installed with v0.6.21, got $(node -v)"
[ "_$(nvm current)" = "_v0.6.21" ] || die "v0.6.21-pre not reported as v0.6.21, got $(nvm current)"

View File

@ -0,0 +1,14 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
nvm deactivate 2>&1 >/dev/null || die 'deactivate failed'
nvm use iojs || die 'nvm use iojs failed'
OUTPUT="$(nvm current)"
EXPECTED_OUTPUT="iojs-v1.0.1"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|| die "'nvm use iojs' + 'nvm current' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"

View File

@ -0,0 +1,14 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
nvm deactivate 2>&1 >/dev/null || die 'deactivate failed'
nvm use node || die 'nvm use node failed'
OUTPUT="$(nvm current)"
EXPECTED_OUTPUT="$(nvm_version stable)"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|| die "'nvm use node' + 'nvm current' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"

View File

@ -0,0 +1,16 @@
#!/bin/sh
. ../../../nvm.sh
mkdir -p ../../../.nvm_use_bak
if [ -d "../../../v*" ]; then
mv "../../../v*" ../../../.nvm_use_bak/
fi
for VERSION in "0.8.7" "0.9.1" "0.10.1" "0.11.1"; do
nvm install "v$VERSION"
done
for VERSION in "1.0.0" "1.0.1"; do
nvm install "iojs-v$VERSION"
done

View File

@ -0,0 +1,16 @@
#!/bin/sh
. ../../../nvm.sh
for VERSION in "0.8.7" "0.9.1" "0.10.1" "0.11.1"; do
nvm uninstall "$VERSION"
done
for VERSION in "1.0.0" "1.0.1"; do
nvm uninstall "iojs-v$VERSION"
done
if [ -d ../../../.nvm_use_bak/* ]; then
mv ../../../.nvm_use_bak/* ../../../
fi
rmdir ../../../.nvm_use_bak