Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0f1f3ed29c | ||
|
|
2116d2ff91 | ||
|
|
0b4c1e14cf | ||
|
|
e1b7496cf0 | ||
|
|
8a87133f71 | ||
|
|
0792945824 | ||
|
|
a6819b3018 | ||
|
|
3d3d9d3a8d | ||
|
|
3e74bac964 | ||
|
|
1eaf6b53e4 | ||
|
|
24c60e4e51 | ||
|
|
8822bd719a | ||
|
|
d90c1eca39 | ||
|
|
223f388693 | ||
|
|
cba5094652 | ||
|
|
b5d9e547f2 | ||
|
|
15598899b6 | ||
|
|
c8f712a334 | ||
|
|
2d9494af45 | ||
|
|
2755227d40 | ||
|
|
dd146519a2 | ||
|
|
7243bd77d3 | ||
|
|
7d113a2b2f | ||
|
|
17df0b9912 | ||
|
|
6cac732141 | ||
|
|
9ee864b06f | ||
|
|
0471d0ffd6 |
@@ -12,11 +12,11 @@ Note: `nvm` does not support Windows (see [#284](https://github.com/creationix/n
|
|||||||
|
|
||||||
To install you could use the [install script][2] using cURL:
|
To install you could use the [install script][2] using cURL:
|
||||||
|
|
||||||
curl https://raw.githubusercontent.com/creationix/nvm/v0.23.0/install.sh | bash
|
curl https://raw.githubusercontent.com/creationix/nvm/v0.23.3/install.sh | bash
|
||||||
|
|
||||||
or Wget:
|
or Wget:
|
||||||
|
|
||||||
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.23.0/install.sh | bash
|
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.23.3/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>
|
<sub>The script clones the nvm repository to `~/.nvm` and adds the source line to your profile (`~/.bash_profile`, `~/.zshrc` or `~/.profile`).</sub>
|
||||||
|
|
||||||
@@ -72,6 +72,10 @@ In place of a version pointer like "0.10", you can use the special default alias
|
|||||||
nvm use stable
|
nvm use stable
|
||||||
nvm run unstable --version
|
nvm run unstable --version
|
||||||
|
|
||||||
|
If you want to install [io.js](https://github.com/iojs/io.js/):
|
||||||
|
|
||||||
|
nvm install iojs
|
||||||
|
|
||||||
If you want to use the system-installed version of node, you can use the special default alias "system":
|
If you want to use the system-installed version of node, you can use the special default alias "system":
|
||||||
|
|
||||||
nvm use system
|
nvm use system
|
||||||
@@ -100,6 +104,13 @@ To use a mirror of the node binaries, set `$NVM_NODEJS_ORG_MIRROR`:
|
|||||||
|
|
||||||
NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist nvm install 0.10
|
NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist nvm install 0.10
|
||||||
|
|
||||||
|
To use a mirror of the iojs binaries, set `$NVM_IOJS_ORG_MIRROR`:
|
||||||
|
|
||||||
|
export NVM_IOJS_ORG_MIRROR=https://iojs.org/dist
|
||||||
|
nvm install iojs-v1.0.3
|
||||||
|
|
||||||
|
NVM_IOJS_ORG_MIRROR=https://iojs.org/dist nvm install iojs-v1.0.3
|
||||||
|
|
||||||
`nvm use` will not, by default, create a "current" symlink. Set `$NVM_SYMLINK_CURRENT` to "true" to enable this behavior, which is sometimes useful for IDEs.
|
`nvm use` will not, by default, create a "current" symlink. Set `$NVM_SYMLINK_CURRENT` to "true" to enable this behavior, which is sometimes useful for IDEs.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
@@ -191,7 +202,7 @@ After the v0.8.6 release of node, nvm tries to install from binary packages. But
|
|||||||
nvm install -s 0.8.6
|
nvm install -s 0.8.6
|
||||||
|
|
||||||
[1]: https://github.com/creationix/nvm.git
|
[1]: https://github.com/creationix/nvm.git
|
||||||
[2]: https://github.com/creationix/nvm/blob/v0.23.0/install.sh
|
[2]: https://github.com/creationix/nvm/blob/v0.23.3/install.sh
|
||||||
[3]: https://travis-ci.org/creationix/nvm
|
[3]: https://travis-ci.org/creationix/nvm
|
||||||
[Urchin]: https://github.com/scraperwiki/urchin
|
[Urchin]: https://github.com/scraperwiki/urchin
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ if [ -z "$NVM_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
nvm_latest_version() {
|
nvm_latest_version() {
|
||||||
echo "v0.23.0"
|
echo "v0.23.3"
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -57,7 +57,7 @@ nvm_download() {
|
|||||||
|
|
||||||
install_nvm_from_git() {
|
install_nvm_from_git() {
|
||||||
if [ -d "$NVM_DIR/.git" ]; then
|
if [ -d "$NVM_DIR/.git" ]; then
|
||||||
echo "=> nvm is already installed in $NVM_DIR, trying to update"
|
echo "=> nvm is already installed in $NVM_DIR, trying to update using git"
|
||||||
printf "\r=> "
|
printf "\r=> "
|
||||||
cd "$NVM_DIR" && (command git fetch 2> /dev/null || {
|
cd "$NVM_DIR" && (command git fetch 2> /dev/null || {
|
||||||
echo >&2 "Failed to update nvm, run 'git fetch' in $NVM_DIR yourself." && exit 1
|
echo >&2 "Failed to update nvm, run 'git fetch' in $NVM_DIR yourself." && exit 1
|
||||||
@@ -82,7 +82,7 @@ install_nvm_as_script() {
|
|||||||
# Downloading to $NVM_DIR
|
# Downloading to $NVM_DIR
|
||||||
mkdir -p "$NVM_DIR"
|
mkdir -p "$NVM_DIR"
|
||||||
if [ -d "$NVM_DIR/nvm.sh" ]; then
|
if [ -d "$NVM_DIR/nvm.sh" ]; then
|
||||||
echo "=> nvm is already installed in $NVM_DIR, trying to update"
|
echo "=> nvm is already installed in $NVM_DIR, trying to update the script"
|
||||||
else
|
else
|
||||||
echo "=> Downloading nvm as script to '$NVM_DIR'"
|
echo "=> Downloading nvm as script to '$NVM_DIR'"
|
||||||
fi
|
fi
|
||||||
|
|||||||
128
nvm.sh
128
nvm.sh
@@ -217,18 +217,68 @@ nvm_remote_version() {
|
|||||||
local PATTERN
|
local PATTERN
|
||||||
PATTERN="$1"
|
PATTERN="$1"
|
||||||
local VERSION
|
local VERSION
|
||||||
if nvm_is_iojs_version "$PATTERN"; then
|
if nvm_validate_implicit_alias "$PATTERN" 2> /dev/null ; then
|
||||||
VERSION="$(nvm_ls_remote_iojs "$PATTERN")"
|
|
||||||
else
|
|
||||||
VERSION="$(nvm_ls_remote "$PATTERN")"
|
VERSION="$(nvm_ls_remote "$PATTERN")"
|
||||||
|
else
|
||||||
|
case "_$PATTERN" in
|
||||||
|
"_$(nvm_node_prefix)")
|
||||||
|
VERSION="$(nvm_ls_remote stable)"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
VERSION="$(nvm_remote_versions "$PATTERN" | tail -n1)"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
echo "$VERSION" | tail -n1
|
echo "$VERSION"
|
||||||
|
|
||||||
if [ "_$VERSION" = '_N/A' ]; then
|
if [ "_$VERSION" = '_N/A' ]; then
|
||||||
return 3
|
return 3
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nvm_remote_versions() {
|
||||||
|
local PATTERN
|
||||||
|
PATTERN="$1"
|
||||||
|
if nvm_validate_implicit_alias "$PATTERN" 2> /dev/null ; then
|
||||||
|
echo >&2 "Implicit aliases are not supported in nvm_remote_versions."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
case "_$PATTERN" in
|
||||||
|
"_$(nvm_iojs_prefix)" | "_io.js")
|
||||||
|
VERSIONS="$(nvm_ls_remote_iojs)"
|
||||||
|
;;
|
||||||
|
"_$(nvm_node_prefix)")
|
||||||
|
VERSIONS="$(nvm_ls_remote)"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
VERSIONS="$(echo "$(nvm_ls_remote "$PATTERN")
|
||||||
|
$(nvm_ls_remote_iojs "$PATTERN")" | command grep -v "N/A" | command sed '/^$/d')"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -z "$VERSIONS" ]; then
|
||||||
|
echo "N/A"
|
||||||
|
return 3
|
||||||
|
else
|
||||||
|
echo "$VERSIONS"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
nvm_is_valid_version() {
|
||||||
|
if nvm_validate_implicit_alias "$1" 2> /dev/null; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
case "$1" in
|
||||||
|
"$(nvm_iojs_prefix)" | "$(nvm_node_prefix)")
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
local VERSION
|
||||||
|
VERSION="$(nvm_strip_iojs_prefix "$1")"
|
||||||
|
nvm_version_greater "$VERSION"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
nvm_normalize_version() {
|
nvm_normalize_version() {
|
||||||
echo "$1" | command sed -e 's/^v//' | command awk -F. '{ printf("%d%06d%06d\n", $1,$2,$3); }'
|
echo "$1" | command sed -e 's/^v//' | command awk -F. '{ printf("%d%06d%06d\n", $1,$2,$3); }'
|
||||||
}
|
}
|
||||||
@@ -435,6 +485,8 @@ nvm_ls() {
|
|||||||
if [ "_$(echo "$PATTERN" | cut -c1-1)" = "_v" ] && [ "_$(nvm_num_version_groups "$PATTERN")" = "_3" ]; then
|
if [ "_$(echo "$PATTERN" | cut -c1-1)" = "_v" ] && [ "_$(nvm_num_version_groups "$PATTERN")" = "_3" ]; then
|
||||||
if [ -d "$(nvm_version_path "$PATTERN")" ]; then
|
if [ -d "$(nvm_version_path "$PATTERN")" ]; then
|
||||||
VERSIONS="$PATTERN"
|
VERSIONS="$PATTERN"
|
||||||
|
elif [ -d "$(nvm_version_path "$(nvm_add_iojs_prefix "$PATTERN")")" ]; then
|
||||||
|
VERSIONS="$(nvm_add_iojs_prefix "$PATTERN")"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
case "$PATTERN" in
|
case "$PATTERN" in
|
||||||
@@ -489,6 +541,7 @@ nvm_ls() {
|
|||||||
fi
|
fi
|
||||||
VERSIONS="$(command find $NVM_DIRS_TO_SEARCH -maxdepth 1 -type d -name "$PATTERN*" \
|
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_version_dir iojs)/#"$(nvm_iojs_prefix)"-#" \
|
||||||
|
| command grep -v "$(nvm_version_dir iojs)" \
|
||||||
| command sed "s#^$NVM_DIR/##" \
|
| command sed "s#^$NVM_DIR/##" \
|
||||||
| command grep -v -e '^versions$' \
|
| command grep -v -e '^versions$' \
|
||||||
| command sed 's#^versions/##' \
|
| command sed 's#^versions/##' \
|
||||||
@@ -527,7 +580,7 @@ nvm_ls_remote() {
|
|||||||
local GREP_OPTIONS
|
local GREP_OPTIONS
|
||||||
GREP_OPTIONS=''
|
GREP_OPTIONS=''
|
||||||
if nvm_validate_implicit_alias "$PATTERN" 2> /dev/null ; then
|
if nvm_validate_implicit_alias "$PATTERN" 2> /dev/null ; then
|
||||||
PATTERN="$(nvm_remote_version "$(nvm_print_implicit_alias remote "$PATTERN")")"
|
PATTERN="$(nvm_ls_remote "$(nvm_print_implicit_alias remote "$PATTERN")" | tail -n1)"
|
||||||
elif [ -n "$PATTERN" ]; then
|
elif [ -n "$PATTERN" ]; then
|
||||||
PATTERN="$(nvm_ensure_version_prefix "$PATTERN")"
|
PATTERN="$(nvm_ensure_version_prefix "$PATTERN")"
|
||||||
else
|
else
|
||||||
@@ -568,9 +621,9 @@ nvm_ls_remote_iojs() {
|
|||||||
|
|
||||||
nvm_checksum() {
|
nvm_checksum() {
|
||||||
if nvm_has "sha1sum"; then
|
if nvm_has "sha1sum"; then
|
||||||
checksum="$(sha1sum "$1" | command awk '{print $1}')"
|
checksum="$(command sha1sum "$1" | command awk '{print $1}')"
|
||||||
elif nvm_has "sha1"; then
|
elif nvm_has "sha1"; then
|
||||||
checksum="$(sha1 -q "$1")"
|
checksum="$(command sha1 -q "$1")"
|
||||||
else
|
else
|
||||||
checksum="$(shasum "$1" | command awk '{print $1}')"
|
checksum="$(shasum "$1" | command awk '{print $1}')"
|
||||||
fi
|
fi
|
||||||
@@ -866,9 +919,6 @@ nvm() {
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Try to figure out the os and arch for binary fetching
|
|
||||||
local os
|
|
||||||
local arch
|
|
||||||
local GREP_OPTIONS
|
local GREP_OPTIONS
|
||||||
GREP_OPTIONS=''
|
GREP_OPTIONS=''
|
||||||
|
|
||||||
@@ -954,17 +1004,12 @@ nvm() {
|
|||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "_$provided_version" in
|
VERSION="$(nvm_remote_version "$provided_version")"
|
||||||
"_$(nvm_iojs_prefix)" | "_io.js")
|
|
||||||
VERSION="$(nvm_add_iojs_prefix $(nvm_ls_remote_iojs | tail -n1))"
|
if [ "_$VERSION" = "_N/A" ]; then
|
||||||
;;
|
echo "Version '$provided_version' not found - try \`nvm ls-remote\` to browse available versions." >&2
|
||||||
"_$(nvm_node_prefix)")
|
return 3
|
||||||
VERSION="$(nvm_ls_remote stable)"
|
fi
|
||||||
;;
|
|
||||||
*)
|
|
||||||
VERSION="$(nvm_remote_version "$provided_version")"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
ADDITIONAL_PARAMETERS=''
|
ADDITIONAL_PARAMETERS=''
|
||||||
local PROVIDED_REINSTALL_PACKAGES_FROM
|
local PROVIDED_REINSTALL_PACKAGES_FROM
|
||||||
@@ -1007,11 +1052,6 @@ nvm() {
|
|||||||
return $?
|
return $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "_$VERSION" = "_N/A" ]; then
|
|
||||||
echo "Version '$provided_version' not found - try \`nvm ls-remote\` to browse available versions." >&2
|
|
||||||
return 3
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "_$NVM_OS" = "_freebsd" ]; then
|
if [ "_$NVM_OS" = "_freebsd" ]; then
|
||||||
# node.js and io.js do not have a FreeBSD binary
|
# node.js and io.js do not have a FreeBSD binary
|
||||||
nobinary=1
|
nobinary=1
|
||||||
@@ -1060,8 +1100,8 @@ nvm() {
|
|||||||
VERSION="$(nvm_version "$PATTERN")"
|
VERSION="$(nvm_version "$PATTERN")"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
if [ "_$PATTERN" = "_$(nvm_ls_current)" ]; then
|
if [ "_$VERSION" = "_$(nvm_ls_current)" ]; then
|
||||||
if nvm_is_iojs_version "$PATTERN"; then
|
if nvm_is_iojs_version "$VERSION"; then
|
||||||
echo "nvm: Cannot uninstall currently-active io.js version, $VERSION (inferred from $PATTERN)." >&2
|
echo "nvm: Cannot uninstall currently-active io.js version, $VERSION (inferred from $PATTERN)." >&2
|
||||||
else
|
else
|
||||||
echo "nvm: Cannot uninstall currently-active node version, $VERSION (inferred from $PATTERN)." >&2
|
echo "nvm: Cannot uninstall currently-active node version, $VERSION (inferred from $PATTERN)." >&2
|
||||||
@@ -1204,7 +1244,11 @@ nvm() {
|
|||||||
if [ "$NVM_SYMLINK_CURRENT" = true ]; then
|
if [ "$NVM_SYMLINK_CURRENT" = true ]; then
|
||||||
command rm -f "$NVM_DIR/current" && ln -s "$NVM_VERSION_DIR" "$NVM_DIR/current"
|
command rm -f "$NVM_DIR/current" && ln -s "$NVM_VERSION_DIR" "$NVM_DIR/current"
|
||||||
fi
|
fi
|
||||||
echo "Now using node $VERSION"
|
if nvm_is_iojs_version "$VERSION"; then
|
||||||
|
echo "Now using io.js $(nvm_strip_iojs_prefix "$VERSION")"
|
||||||
|
else
|
||||||
|
echo "Now using node $VERSION"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
"run" )
|
"run" )
|
||||||
local provided_version
|
local provided_version
|
||||||
@@ -1228,7 +1272,7 @@ nvm() {
|
|||||||
provided_version=$1
|
provided_version=$1
|
||||||
if [ -n "$provided_version" ]; then
|
if [ -n "$provided_version" ]; then
|
||||||
VERSION="$(nvm_version "$provided_version")"
|
VERSION="$(nvm_version "$provided_version")"
|
||||||
if [ "_$VERSION" = "_N/A" ]; then
|
if [ "_$VERSION" = "_N/A" ] && ! nvm_is_valid_version "$provided_version"; then
|
||||||
provided_version=''
|
provided_version=''
|
||||||
if [ $has_checked_nvmrc -ne 1 ]; then
|
if [ $has_checked_nvmrc -ne 1 ]; then
|
||||||
nvm_rc_version && has_checked_nvmrc=1
|
nvm_rc_version && has_checked_nvmrc=1
|
||||||
@@ -1247,17 +1291,23 @@ nvm() {
|
|||||||
local ARGS
|
local ARGS
|
||||||
ARGS="$@"
|
ARGS="$@"
|
||||||
local OUTPUT
|
local OUTPUT
|
||||||
|
local EXIT_CODE
|
||||||
|
|
||||||
if [ "$NVM_IOJS" = true ]; then
|
if [ "_$VERSION" = "_N/A" ]; then
|
||||||
|
echo "$(nvm_ensure_version_prefix "$provided_version") is not installed yet" >&2
|
||||||
|
EXIT_CODE=1
|
||||||
|
elif [ "$NVM_IOJS" = true ]; then
|
||||||
echo "Running io.js $(nvm_strip_iojs_prefix "$VERSION")"
|
echo "Running io.js $(nvm_strip_iojs_prefix "$VERSION")"
|
||||||
OUTPUT="$(nvm use "$VERSION" >/dev/null && iojs "$ARGS")"
|
OUTPUT="$(nvm use "$VERSION" >/dev/null && iojs "$ARGS")"
|
||||||
|
EXIT_CODE="$?"
|
||||||
else
|
else
|
||||||
echo "Running node $VERSION"
|
echo "Running node $VERSION"
|
||||||
OUTPUT="$(nvm use "$VERSION" >/dev/null && node "$ARGS")"
|
OUTPUT="$(nvm use "$VERSION" >/dev/null && node "$ARGS")"
|
||||||
|
EXIT_CODE="$?"
|
||||||
|
fi
|
||||||
|
if [ -n "$OUTPUT" ]; then
|
||||||
|
echo "$OUTPUT"
|
||||||
fi
|
fi
|
||||||
local EXIT_CODE
|
|
||||||
EXIT_CODE="$?"
|
|
||||||
echo "$OUTPUT"
|
|
||||||
return $EXIT_CODE
|
return $EXIT_CODE
|
||||||
;;
|
;;
|
||||||
"exec" )
|
"exec" )
|
||||||
@@ -1327,7 +1377,7 @@ nvm() {
|
|||||||
|
|
||||||
local NVM_OUTPUT
|
local NVM_OUTPUT
|
||||||
NVM_OUTPUT="$(echo "$NVM_LS_REMOTE_OUTPUT
|
NVM_OUTPUT="$(echo "$NVM_LS_REMOTE_OUTPUT
|
||||||
$NVM_LS_REMOTE_IOJS_OUTPUT" | grep -v "N/A" | sed '/^$/d')"
|
$NVM_LS_REMOTE_IOJS_OUTPUT" | command grep -v "N/A" | sed '/^$/d')"
|
||||||
if [ -n "$NVM_OUTPUT" ]; then
|
if [ -n "$NVM_OUTPUT" ]; then
|
||||||
nvm_print_versions "$NVM_OUTPUT"
|
nvm_print_versions "$NVM_OUTPUT"
|
||||||
return $NVM_LS_REMOTE_EXIT_CODE || $NVM_LS_REMOTE_IOJS_EXIT_CODE
|
return $NVM_LS_REMOTE_EXIT_CODE || $NVM_LS_REMOTE_IOJS_EXIT_CODE
|
||||||
@@ -1423,7 +1473,7 @@ $NVM_LS_REMOTE_IOJS_OUTPUT" | grep -v "N/A" | sed '/^$/d')"
|
|||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "! WARNING: Version '$3' does not exist." >&2
|
echo "! WARNING: Version '$3' does not exist." >&2
|
||||||
fi
|
fi
|
||||||
echo "$3" > "$NVM_ALIAS_DIR/$2"
|
echo "$3" | tee "$NVM_ALIAS_DIR/$2"
|
||||||
if [ ! "_$3" = "_$VERSION" ]; then
|
if [ ! "_$3" = "_$VERSION" ]; then
|
||||||
echo "$2 -> $3 (-> $VERSION)"
|
echo "$2 -> $3 (-> $VERSION)"
|
||||||
else
|
else
|
||||||
@@ -1477,14 +1527,14 @@ $NVM_LS_REMOTE_IOJS_OUTPUT" | grep -v "N/A" | sed '/^$/d')"
|
|||||||
nvm_version $2
|
nvm_version $2
|
||||||
;;
|
;;
|
||||||
"--version" )
|
"--version" )
|
||||||
echo "0.23.0"
|
echo "0.23.3"
|
||||||
;;
|
;;
|
||||||
"unload" )
|
"unload" )
|
||||||
unset -f nvm nvm_print_versions nvm_checksum \
|
unset -f nvm nvm_print_versions nvm_checksum \
|
||||||
nvm_iojs_prefix nvm_node_prefix \
|
nvm_iojs_prefix nvm_node_prefix \
|
||||||
nvm_add_iojs_prefix nvm_strip_iojs_prefix \
|
nvm_add_iojs_prefix nvm_strip_iojs_prefix \
|
||||||
nvm_is_iojs_version \
|
nvm_is_iojs_version \
|
||||||
nvm_ls_remote nvm_ls nvm_remote_version \
|
nvm_ls_remote nvm_ls nvm_remote_version nvm_remote_versions \
|
||||||
nvm_version nvm_rc_version \
|
nvm_version nvm_rc_version \
|
||||||
nvm_version_greater nvm_version_greater_than_or_equal_to \
|
nvm_version_greater nvm_version_greater_than_or_equal_to \
|
||||||
nvm_supports_source_options > /dev/null 2>&1
|
nvm_supports_source_options > /dev/null 2>&1
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nvm",
|
"name": "nvm",
|
||||||
"version": "0.23.0",
|
"version": "0.23.3",
|
||||||
"description": "Node Version Manager - Simple bash script to manage multiple active node.js versions",
|
"description": "Node Version Manager - Simple bash script to manage multiple active node.js versions",
|
||||||
"directories": {
|
"directories": {
|
||||||
"test": "test"
|
"test": "test"
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
if [ -n "$ZSH_VERSION" ]; then
|
||||||
|
# set clobber option in order to test that this does not produce any
|
||||||
|
# incompatibilities
|
||||||
|
setopt noclobber
|
||||||
|
fi
|
||||||
|
|
||||||
|
nvm alias test-stable-1 0.0.2
|
||||||
|
|
||||||
|
nvm alias test-stable-1 | \grep -e "test-stable-1 -> 0.0.2 (-> v0.0.2)" \
|
||||||
|
|| die "nvm alias test-stable-1 0.0.2 did not set test-stable-1 to 0.0.2"
|
||||||
|
|
||||||
|
nvm alias test-stable-1 0.0.1
|
||||||
|
|
||||||
|
nvm alias test-stable-1 | \grep -e "test-stable-1 -> 0.0.1 (-> v0.0.1)" \
|
||||||
|
|| die "nvm alias test-stable-1 0.0.1 did not set test-stable-1 to 0.0.1"
|
||||||
7
test/fast/Listing versions/Running "nvm ls io" should return NA
Executable file
7
test/fast/Listing versions/Running "nvm ls io" should return NA
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
nvm ls io
|
||||||
|
[ "$?" = "3" ]
|
||||||
|
|
||||||
22
test/fast/Running "nvm use iojs" uses latest io.js version
Executable file
22
test/fast/Running "nvm use iojs" uses latest io.js version
Executable file
@@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; cleanup ; exit 1; }
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
rm -rf ../../alias/foo
|
||||||
|
}
|
||||||
|
|
||||||
|
. ../../nvm.sh
|
||||||
|
|
||||||
|
echo 'foo' > ../../alias/foo
|
||||||
|
|
||||||
|
OUTPUT="$(nvm use foo 2>&1)"
|
||||||
|
EXPECTED_OUTPUT='The alias "foo" leads to an infinite loop. Aborting.'
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|
||||||
|
|| die "'nvm use foo' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||||
|
|
||||||
|
EXIT_CODE="$(nvm use foo 2>/dev/null ; echo $?)"
|
||||||
|
[ "_$EXIT_CODE" = "_8" ] || die "Expected exit code 8; got $EXIT_CODE"
|
||||||
|
|
||||||
|
cleanup;
|
||||||
|
|
||||||
13
test/fast/Unit tests/nvm_is_valid_version
Executable file
13
test/fast/Unit tests/nvm_is_valid_version
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
nvm_is_valid_version 0.1.2 || die "nvm_is_valid_version 0.1.2 did not return 0"
|
||||||
|
nvm_is_valid_version foo && die "nvm_is_valid_version foo did not return 1"
|
||||||
|
nvm_is_valid_version iojs-1 || die "nvm_is_valid_version iojs-1 did not return 0"
|
||||||
|
nvm_is_valid_version iojs || die "nvm_is_valid_version iojs did not return 0"
|
||||||
|
nvm_is_valid_version node || die "nvm_is_valid_version node did not return 0"
|
||||||
|
nvm_is_valid_version stable || die "nvm_is_valid_version stable did not return 0"
|
||||||
|
nvm_is_valid_version unstable || die "nvm_is_valid_version unstable did not return 0"
|
||||||
@@ -26,9 +26,18 @@ EXIT_CODE="$(nvm_remote_version iojs-foo >/dev/null 2>&1 ; echo $?)"
|
|||||||
|
|
||||||
|
|
||||||
nvm_ls_remote() {
|
nvm_ls_remote() {
|
||||||
echo "test output"
|
if ! nvm_is_iojs_version "$1"; then
|
||||||
echo "more test output"
|
echo "test output"
|
||||||
echo "pattern received: _$1_"
|
echo "more test output"
|
||||||
|
echo "pattern received: _$1_"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
nvm_ls_remote_iojs() {
|
||||||
|
if nvm_is_iojs_version "$1"; then
|
||||||
|
echo "test iojs output"
|
||||||
|
echo "more iojs test output"
|
||||||
|
echo "iojs pattern received: _$1_"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
OUTPUT="$(nvm_remote_version foo)"
|
OUTPUT="$(nvm_remote_version foo)"
|
||||||
EXIT_CODE="$(nvm_remote_version foo >/dev/null 2>&1 ; echo $?)"
|
EXIT_CODE="$(nvm_remote_version foo >/dev/null 2>&1 ; echo $?)"
|
||||||
@@ -36,17 +45,17 @@ EXIT_CODE="$(nvm_remote_version foo >/dev/null 2>&1 ; echo $?)"
|
|||||||
|| die "nvm_remote_version foo did not return last line only of nvm_ls_remote foo; got $OUTPUT"
|
|| 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"
|
[ "_$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)"
|
OUTPUT="$(nvm_remote_version iojs-foo)"
|
||||||
EXIT_CODE="$(nvm_remote_version iojs-foo >/dev/null 2>&1 ; echo $?)"
|
EXIT_CODE="$(nvm_remote_version iojs-foo >/dev/null 2>&1 ; echo $?)"
|
||||||
[ "_$OUTPUT" = "_iojs pattern received: _iojs-foo_" ] \
|
[ "_$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"
|
|| 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"
|
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version iojs-foo did not exit with 0, got $EXIT_CODE"
|
||||||
|
|
||||||
|
OUTPUT="$(nvm_remote_version stable)"
|
||||||
|
EXIT_CODE="$(nvm_remote_version stable >/dev/null 2>&1 ; echo $?)"
|
||||||
|
[ "_$OUTPUT" = "_$(nvm_ls_remote stable)" ] \
|
||||||
|
|| die "nvm_remote_version stable did not return contents of nvm_ls_remote stable; got $OUTPUT"
|
||||||
|
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version stable did not exit with 0, got $EXIT_CODE"
|
||||||
|
|
||||||
cleanup
|
cleanup
|
||||||
|
|
||||||
|
|||||||
78
test/fast/Unit tests/nvm_remote_versions
Executable file
78
test/fast/Unit tests/nvm_remote_versions
Executable file
@@ -0,0 +1,78 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; cleanup ; exit 1; }
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
unset -f nvm_ls_remote nvm_ls_remote_iojs
|
||||||
|
}
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
OUTPUT="$(nvm_remote_versions stable 2>&1)"
|
||||||
|
EXPECTED_OUTPUT="Implicit aliases are not supported in nvm_remote_versions."
|
||||||
|
EXIT_CODE="$(nvm_remote_versions stable >/dev/null 2>&1; echo $?)"
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "implicit alias 'stable' did not error out with correct message, got $OUTPUT"
|
||||||
|
[ "_$EXIT_CODE" = "_1" ] || die "implicit alias 'stable' did not exit with code 1, got $EXIT_CODE"
|
||||||
|
|
||||||
|
OUTPUT="$(nvm_remote_versions unstable 2>&1)"
|
||||||
|
EXPECTED_OUTPUT="Implicit aliases are not supported in nvm_remote_versions."
|
||||||
|
EXIT_CODE="$(nvm_remote_versions unstable >/dev/null 2>&1; echo $?)"
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "implicit alias 'unstable' did not error out with correct message, got $OUTPUT"
|
||||||
|
[ "_$EXIT_CODE" = "_1" ] || die "implicit alias 'unstable' did not exit with code 1, got $EXIT_CODE"
|
||||||
|
|
||||||
|
nvm_ls_remote() {
|
||||||
|
echo "N/A"
|
||||||
|
}
|
||||||
|
OUTPUT="$(nvm_remote_versions foo)"
|
||||||
|
EXIT_CODE="$(nvm_remote_versions 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_versions iojs-foo)"
|
||||||
|
EXIT_CODE="$(nvm_remote_versions 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_"
|
||||||
|
}
|
||||||
|
nvm_ls_remote_iojs() {
|
||||||
|
echo "test iojs output"
|
||||||
|
echo "more iojs test output"
|
||||||
|
echo "iojs pattern received: _$1_"
|
||||||
|
}
|
||||||
|
|
||||||
|
OUTPUT="$(nvm_remote_versions foo)"
|
||||||
|
EXIT_CODE="$(nvm_remote_versions foo >/dev/null 2>&1 ; echo $?)"
|
||||||
|
[ "_$OUTPUT" = "_$(nvm_ls_remote foo)
|
||||||
|
$(nvm_ls_remote_iojs foo)" ] \
|
||||||
|
|| die "nvm_remote_versions foo did not return contents of nvm_ls_remote foo combined with nvm_ls_remote_iojs foo; got $OUTPUT"
|
||||||
|
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_versions foo did not exit with 0, got $EXIT_CODE"
|
||||||
|
|
||||||
|
OUTPUT="$(nvm_remote_versions node)"
|
||||||
|
EXIT_CODE="$(nvm_remote_versions node >/dev/null 2>&1 ; echo $?)"
|
||||||
|
[ "_$OUTPUT" = "_$(nvm_ls_remote)" ] \
|
||||||
|
|| die "nvm_remote_versions node did not return contents of nvm_ls_remote; got $OUTPUT"
|
||||||
|
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_versions node did not exit with 0, got $EXIT_CODE"
|
||||||
|
|
||||||
|
OUTPUT="$(nvm_remote_versions iojs-foo)"
|
||||||
|
EXIT_CODE="$(nvm_remote_versions iojs-foo >/dev/null 2>&1 ; echo $?)"
|
||||||
|
[ "_$OUTPUT" = "_$(nvm_ls_remote iojs-foo)
|
||||||
|
$(nvm_ls_remote_iojs iojs-foo)" ] \
|
||||||
|
|| die "nvm_remote_versions iojs-foo did not return contents of nvm_ls_remote iojs-foo combined with nvm_ls_remote_iojs iojs-foo; got $OUTPUT"
|
||||||
|
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_versions iojs-foo did not exit with 0, got $EXIT_CODE"
|
||||||
|
|
||||||
|
OUTPUT="$(nvm_remote_versions iojs)"
|
||||||
|
EXIT_CODE="$(nvm_remote_versions iojs >/dev/null 2>&1 ; echo $?)"
|
||||||
|
[ "_$OUTPUT" = "_$(nvm_ls_remote_iojs)" ] \
|
||||||
|
|| die "nvm_remote_versions iojs did not return contents of nvm_ls_remote_iojs; got $OUTPUT"
|
||||||
|
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_versions iojs did not exit with 0, got $EXIT_CODE"
|
||||||
|
|
||||||
|
cleanup
|
||||||
|
|
||||||
20
test/installation/io.js/nvm install v1 works
Executable file
20
test/installation/io.js/nvm install v1 works
Executable file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
NVM_VERSION="v1"
|
||||||
|
NVM_PREFIXED_TEST_VERSION="$(nvm ls-remote "$NVM_VERSION" | tail -n1 | sed 's/^[ ]*//;s/[ ]*$//')"
|
||||||
|
NVM_TEST_VERSION="$(nvm_strip_iojs_prefix "$NVM_PREFIXED_TEST_VERSION")"
|
||||||
|
|
||||||
|
# Remove the stuff we're clobbering.
|
||||||
|
[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION
|
||||||
|
|
||||||
|
# Install from binary
|
||||||
|
nvm install "$NVM_VERSION" || die "nvm install $NVM_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"
|
||||||
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
[ "$(nvm run 0.2 --version 2>&1)" = "v0.2 is not installed yet" ] || die "\`nvm run\` with an uninstalled node version failed to error out correctly"
|
||||||
|
[ "$(nvm run iojs-0.2 --version 2>&1)" = "iojs-v0.2 is not installed yet" ] || die "\`nvm run\` with an uninstalled iojs version failed to error out correctly"
|
||||||
14
test/slow/nvm use/Running "nvm use v1.0.0" uses iojs-v1.0.0 iojs version
Executable file
14
test/slow/nvm use/Running "nvm use v1.0.0" uses iojs-v1.0.0 iojs version
Executable file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
nvm deactivate 2>&1 >/dev/null || die 'deactivate failed'
|
||||||
|
|
||||||
|
nvm use 'v1.0.0' || die 'nvm use v1.0.0 failed'
|
||||||
|
OUTPUT="$(nvm current)"
|
||||||
|
EXPECTED_OUTPUT="$(nvm_version v1.0.0)"
|
||||||
|
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|
||||||
|
|| die "'nvm use v1.0.0' + 'nvm current' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||||
Reference in New Issue
Block a user