Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2176894a5b | ||
|
|
cf7d5d8042 | ||
|
|
7135873f80 | ||
|
|
dc9020b133 | ||
|
|
0eaa7e0bde | ||
|
|
06b81f0f36 | ||
|
|
8a20234586 | ||
|
|
44541b416f | ||
|
|
731c2f3f70 | ||
|
|
de64a2d95f | ||
|
|
77e0449c89 | ||
|
|
649e416017 | ||
|
|
754a0d7c5b | ||
|
|
f73bfb6578 | ||
|
|
f1bca106a8 | ||
|
|
560c8c9500 |
@@ -25,11 +25,11 @@ Homebrew installation is not supported.
|
|||||||
|
|
||||||
To install or update nvm, you can use the [install script][2] using cURL:
|
To install or update nvm, you can use the [install script][2] using cURL:
|
||||||
|
|
||||||
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh | bash
|
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash
|
||||||
|
|
||||||
or Wget:
|
or Wget:
|
||||||
|
|
||||||
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh | bash
|
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/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>
|
||||||
|
|
||||||
@@ -60,6 +60,10 @@ Add these lines to your `~/.bashrc`, `~/.profile`, or `~/.zshrc` file to have it
|
|||||||
For manual upgrade with `git`, change to the `$NVM_DIR`, pull down the latest changes, and check out the latest version:
|
For manual upgrade with `git`, change to the `$NVM_DIR`, pull down the latest changes, and check out the latest version:
|
||||||
|
|
||||||
cd "$NVM_DIR" && git pull origin master && git checkout `git describe --abbrev=0 --tags`
|
cd "$NVM_DIR" && git pull origin master && git checkout `git describe --abbrev=0 --tags`
|
||||||
|
|
||||||
|
After upgrading, don't forget to activate the new version:
|
||||||
|
|
||||||
|
. "$NVM_DIR/nvm.sh"
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@@ -260,7 +264,7 @@ After the v0.8.6 release of node, nvm tries to install from binary packages. But
|
|||||||
If setting the `default` alias does not establish the node version in new shells (i.e. `nvm current` yields `system`), ensure that the system's node PATH is set before the `nvm.sh` source line in your shell profile (see [#658](https://github.com/creationix/nvm/issues/658))
|
If setting the `default` alias does not establish the node version in new shells (i.e. `nvm current` yields `system`), ensure that the system's node PATH is set before the `nvm.sh` source line in your shell profile (see [#658](https://github.com/creationix/nvm/issues/658))
|
||||||
|
|
||||||
[1]: https://github.com/creationix/nvm.git
|
[1]: https://github.com/creationix/nvm.git
|
||||||
[2]: https://github.com/creationix/nvm/blob/v0.30.2/install.sh
|
[2]: https://github.com/creationix/nvm/blob/v0.31.0/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
|
||||||
[Fish]: http://fishshell.com
|
[Fish]: http://fishshell.com
|
||||||
|
|||||||
12
install.sh
12
install.sh
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
{ # this ensures the entire script is downloaded #
|
{ # this ensures the entire script is downloaded #
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ if [ -z "$NVM_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
nvm_latest_version() {
|
nvm_latest_version() {
|
||||||
echo "v0.30.2"
|
echo "v0.31.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -69,7 +69,7 @@ install_nvm_from_git() {
|
|||||||
mkdir -p "$NVM_DIR"
|
mkdir -p "$NVM_DIR"
|
||||||
command git clone "$(nvm_source git)" "$NVM_DIR"
|
command git clone "$(nvm_source git)" "$NVM_DIR"
|
||||||
fi
|
fi
|
||||||
cd "$NVM_DIR" && command git checkout --quiet $(nvm_latest_version)
|
cd "$NVM_DIR" && command git checkout --quiet "$(nvm_latest_version)"
|
||||||
if [ ! -z "$(cd "$NVM_DIR" && git show-ref refs/heads/master)" ]; then
|
if [ ! -z "$(cd "$NVM_DIR" && git show-ref refs/heads/master)" ]; then
|
||||||
if git branch --quiet 2>/dev/null; then
|
if git branch --quiet 2>/dev/null; then
|
||||||
cd "$NVM_DIR" && command git branch --quiet -D master >/dev/null 2>&1
|
cd "$NVM_DIR" && command git branch --quiet -D master >/dev/null 2>&1
|
||||||
@@ -123,15 +123,15 @@ nvm_detect_profile() {
|
|||||||
local DETECTED_PROFILE
|
local DETECTED_PROFILE
|
||||||
DETECTED_PROFILE=''
|
DETECTED_PROFILE=''
|
||||||
local SHELLTYPE
|
local SHELLTYPE
|
||||||
SHELLTYPE="$(basename /$SHELL)"
|
SHELLTYPE="$(basename "/$SHELL")"
|
||||||
|
|
||||||
if [ $SHELLTYPE = "bash" ]; then
|
if [ "$SHELLTYPE" = "bash" ]; then
|
||||||
if [ -f "$HOME/.bashrc" ]; then
|
if [ -f "$HOME/.bashrc" ]; then
|
||||||
DETECTED_PROFILE="$HOME/.bashrc"
|
DETECTED_PROFILE="$HOME/.bashrc"
|
||||||
elif [ -f "$HOME/.bash_profile" ]; then
|
elif [ -f "$HOME/.bash_profile" ]; then
|
||||||
DETECTED_PROFILE="$HOME/.bash_profile"
|
DETECTED_PROFILE="$HOME/.bash_profile"
|
||||||
fi
|
fi
|
||||||
elif [ $SHELLTYPE = "zsh" ]; then
|
elif [ "$SHELLTYPE" = "zsh" ]; then
|
||||||
DETECTED_PROFILE="$HOME/.zshrc"
|
DETECTED_PROFILE="$HOME/.zshrc"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
9
nvm-exec
9
nvm-exec
@@ -1,13 +1,14 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
DIR="$(command cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
DIR="$(command cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
. "$DIR/nvm.sh" --no-use
|
. "$DIR/nvm.sh" --no-use
|
||||||
|
|
||||||
if [ -n "$NODE_VERSION" ]; then
|
if [ -n "$NODE_VERSION" ]; then
|
||||||
nvm use $NODE_VERSION > /dev/null || (echo "NODE_VERSION not set" >&2 && exit 127)
|
nvm use $NODE_VERSION > /dev/null || exit 127
|
||||||
else
|
elif ! nvm use >/dev/null 2>&1; then
|
||||||
nvm use > /dev/null || (echo "No .nvmrc file found" >&2 && exit 127)
|
echo "No NODE_VERSION provided; no .nvmrc file found" >&2
|
||||||
|
exit 127
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec "$@"
|
exec "$@"
|
||||||
|
|||||||
114
nvm.sh
114
nvm.sh
@@ -339,10 +339,12 @@ nvm_ensure_version_prefix() {
|
|||||||
nvm_format_version() {
|
nvm_format_version() {
|
||||||
local VERSION
|
local VERSION
|
||||||
VERSION="$(nvm_ensure_version_prefix "$1")"
|
VERSION="$(nvm_ensure_version_prefix "$1")"
|
||||||
if [ "_$(nvm_num_version_groups "$VERSION")" != "_3" ]; then
|
local NUM_GROUPS
|
||||||
|
NUM_GROUPS="$(nvm_num_version_groups "$VERSION")"
|
||||||
|
if [ $NUM_GROUPS -lt 3 ]; then
|
||||||
nvm_format_version "${VERSION%.}.0"
|
nvm_format_version "${VERSION%.}.0"
|
||||||
else
|
else
|
||||||
echo "$VERSION"
|
echo "$VERSION" | cut -f1-3 -d.
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -759,15 +761,37 @@ nvm_ls_remote_index_tab() {
|
|||||||
|
|
||||||
nvm_checksum() {
|
nvm_checksum() {
|
||||||
local NVM_CHECKSUM
|
local NVM_CHECKSUM
|
||||||
if nvm_has "sha1sum" && ! nvm_is_alias "sha1sum"; then
|
if [ -z "$3" ] || [ "$3" == "sha1" ]; then
|
||||||
NVM_CHECKSUM="$(command sha1sum "$1" | command awk '{print $1}')"
|
if nvm_has "sha1sum" && ! nvm_is_alias "sha1sum"; then
|
||||||
elif nvm_has "sha1" && ! nvm_is_alias "sha1"; then
|
NVM_CHECKSUM="$(command sha1sum "$1" | command awk '{print $1}')"
|
||||||
NVM_CHECKSUM="$(command sha1 -q "$1")"
|
elif nvm_has "sha1" && ! nvm_is_alias "sha1"; then
|
||||||
elif nvm_has "shasum" && ! nvm_is_alias "shasum"; then
|
NVM_CHECKSUM="$(command sha1 -q "$1")"
|
||||||
NVM_CHECKSUM="$(shasum "$1" | command awk '{print $1}')"
|
elif nvm_has "shasum" && ! nvm_is_alias "shasum"; then
|
||||||
|
NVM_CHECKSUM="$(shasum "$1" | command awk '{print $1}')"
|
||||||
|
else
|
||||||
|
echo "Unaliased sha1sum, sha1, or shasum not found." >&2
|
||||||
|
return 2
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "Unaliased sha1sum, sha1, or shasum not found." >&2
|
if nvm_has "sha256sum" && ! nvm_is_alias "sha256sum"; then
|
||||||
return 2
|
NVM_CHECKSUM="$(sha256sum "$1" | awk '{print $1}')"
|
||||||
|
elif nvm_has "shasum" && ! nvm_is_alias "shasum"; then
|
||||||
|
NVM_CHECKSUM="$(shasum -a 256 "$1" | awk '{print $1}')"
|
||||||
|
elif nvm_has "sha256" && ! nvm_is_alias "sha256"; then
|
||||||
|
NVM_CHECKSUM="$(sha256 -q "$1" | awk '{print $1}')"
|
||||||
|
elif nvm_has "gsha256sum" && ! nvm_is_alias "gsha256sum"; then
|
||||||
|
NVM_CHECKSUM="$(gsha256sum "$1" | awk '{print $1}')"
|
||||||
|
elif nvm_has "openssl" && ! nvm_is_alias "openssl"; then
|
||||||
|
NVM_CHECKSUM="$(openssl dgst -sha256 "$1" | rev | awk '{print $1}' | rev)"
|
||||||
|
elif nvm_has "libressl" && ! nvm_is_alias "libressl"; then
|
||||||
|
NVM_CHECKSUM="$(libressl dgst -sha256 "$1" | rev | awk '{print $1}' | rev)"
|
||||||
|
elif nvm_has "bssl" && ! nvm_is_alias "bssl"; then
|
||||||
|
NVM_CHECKSUM="$(bssl sha256sum "$1" | awk '{print $1}')"
|
||||||
|
else
|
||||||
|
echo "Unaliased sha256sum, shasum, sha256, gsha256sum, openssl, libressl, or bssl not found." >&2
|
||||||
|
echo "WARNING: Continuing *without checksum verification*" >&2
|
||||||
|
return
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "_$NVM_CHECKSUM" = "_$2" ]; then
|
if [ "_$NVM_CHECKSUM" = "_$2" ]; then
|
||||||
@@ -971,6 +995,34 @@ nvm_get_arch() {
|
|||||||
echo "$NVM_ARCH"
|
echo "$NVM_ARCH"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nvm_get_minor_version() {
|
||||||
|
local VERSION
|
||||||
|
VERSION="$1"
|
||||||
|
|
||||||
|
if [ -z "$VERSION" ]; then
|
||||||
|
echo 'a version is required' >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$VERSION" in
|
||||||
|
v | .* | *..* | v*[!.0123456789]* | [!v]*[!.0123456789]* | [!v0123456789]* | v[!0123456789]*)
|
||||||
|
echo 'invalid version number' >&2
|
||||||
|
return 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
local PREFIXED_VERSION
|
||||||
|
PREFIXED_VERSION="$(nvm_format_version "$VERSION")"
|
||||||
|
|
||||||
|
local MINOR
|
||||||
|
MINOR="$(echo "$PREFIXED_VERSION" | command grep -e '^v' | command cut -c2- | command cut -d . -f 1,2)"
|
||||||
|
if [ -z "$MINOR" ]; then
|
||||||
|
echo 'invalid version number! (please report this)' >&2
|
||||||
|
return 3
|
||||||
|
fi
|
||||||
|
echo "$MINOR"
|
||||||
|
}
|
||||||
|
|
||||||
nvm_ensure_default_set() {
|
nvm_ensure_default_set() {
|
||||||
local VERSION
|
local VERSION
|
||||||
VERSION="$1"
|
VERSION="$1"
|
||||||
@@ -1051,8 +1103,7 @@ nvm_install_merged_node_binary() {
|
|||||||
fi
|
fi
|
||||||
if (
|
if (
|
||||||
[ "$NVM_INSTALL_ERRORED" != true ] && \
|
[ "$NVM_INSTALL_ERRORED" != true ] && \
|
||||||
echo "WARNING: checksums are currently disabled for node.js v4.0 and later" >&2 && \
|
nvm_checksum "$tmptarball" "$sum" "sha256" && \
|
||||||
# nvm_checksum "$tmptarball" "$sum" && \
|
|
||||||
command tar -x${tar_compression_flag}f "$tmptarball" -C "$tmpdir" --strip-components 1 && \
|
command tar -x${tar_compression_flag}f "$tmptarball" -C "$tmpdir" --strip-components 1 && \
|
||||||
command rm -f "$tmptarball" && \
|
command rm -f "$tmptarball" && \
|
||||||
command mkdir -p "$VERSION_PATH" && \
|
command mkdir -p "$VERSION_PATH" && \
|
||||||
@@ -1126,8 +1177,7 @@ nvm_install_iojs_binary() {
|
|||||||
fi
|
fi
|
||||||
if (
|
if (
|
||||||
[ "$NVM_INSTALL_ERRORED" != true ] && \
|
[ "$NVM_INSTALL_ERRORED" != true ] && \
|
||||||
echo "WARNING: checksums are currently disabled for io.js" >&2 && \
|
nvm_checksum "$tmptarball" "$sum" "sha256" && \
|
||||||
# nvm_checksum "$tmptarball" "$sum" && \
|
|
||||||
command tar -x${tar_compression_flag}f "$tmptarball" -C "$tmpdir" --strip-components 1 && \
|
command tar -x${tar_compression_flag}f "$tmptarball" -C "$tmpdir" --strip-components 1 && \
|
||||||
command rm -f "$tmptarball" && \
|
command rm -f "$tmptarball" && \
|
||||||
command mkdir -p "$VERSION_PATH" && \
|
command mkdir -p "$VERSION_PATH" && \
|
||||||
@@ -1680,6 +1730,7 @@ nvm() {
|
|||||||
if nvm use "$VERSION" && [ ! -z "$REINSTALL_PACKAGES_FROM" ] && [ "_$REINSTALL_PACKAGES_FROM" != "_N/A" ]; then
|
if nvm use "$VERSION" && [ ! -z "$REINSTALL_PACKAGES_FROM" ] && [ "_$REINSTALL_PACKAGES_FROM" != "_N/A" ]; then
|
||||||
nvm reinstall-packages "$REINSTALL_PACKAGES_FROM"
|
nvm reinstall-packages "$REINSTALL_PACKAGES_FROM"
|
||||||
fi
|
fi
|
||||||
|
nvm_ensure_default_set "$provided_version"
|
||||||
return $?
|
return $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -1725,6 +1776,7 @@ nvm() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$NVM_INSTALL_SUCCESS" = true ] && nvm use "$VERSION"; then
|
if [ "$NVM_INSTALL_SUCCESS" = true ] && nvm use "$VERSION"; then
|
||||||
|
nvm_ensure_default_set "$provided_version"
|
||||||
if [ ! -z "$REINSTALL_PACKAGES_FROM" ] \
|
if [ ! -z "$REINSTALL_PACKAGES_FROM" ] \
|
||||||
&& [ "_$REINSTALL_PACKAGES_FROM" != "_N/A" ]; then
|
&& [ "_$REINSTALL_PACKAGES_FROM" != "_N/A" ]; then
|
||||||
nvm reinstall-packages "$REINSTALL_PACKAGES_FROM"
|
nvm reinstall-packages "$REINSTALL_PACKAGES_FROM"
|
||||||
@@ -2300,7 +2352,7 @@ $NVM_LS_REMOTE_POST_MERGED_OUTPUT" | command grep -v "N/A" | command sed '/^$/d'
|
|||||||
nvm_remote_version "$2"
|
nvm_remote_version "$2"
|
||||||
;;
|
;;
|
||||||
"--version" )
|
"--version" )
|
||||||
echo "0.30.2"
|
echo "0.31.0"
|
||||||
;;
|
;;
|
||||||
"unload" )
|
"unload" )
|
||||||
unset -f nvm nvm_print_versions nvm_checksum \
|
unset -f nvm nvm_print_versions nvm_checksum \
|
||||||
@@ -2325,7 +2377,8 @@ $NVM_LS_REMOTE_POST_MERGED_OUTPUT" | command grep -v "N/A" | command sed '/^$/d'
|
|||||||
nvm_print_npm_version nvm_npm_global_modules \
|
nvm_print_npm_version nvm_npm_global_modules \
|
||||||
nvm_has_system_node nvm_has_system_iojs \
|
nvm_has_system_node nvm_has_system_iojs \
|
||||||
nvm_download nvm_get_latest nvm_has nvm_get_latest \
|
nvm_download nvm_get_latest nvm_has nvm_get_latest \
|
||||||
nvm_supports_source_options nvm_auto nvm_supports_xz > /dev/null 2>&1
|
nvm_supports_source_options nvm_auto nvm_supports_xz \
|
||||||
|
nvm_process_parameters > /dev/null 2>&1
|
||||||
unset RC_VERSION NVM_NODEJS_ORG_MIRROR NVM_DIR NVM_CD_FLAGS > /dev/null 2>&1
|
unset RC_VERSION NVM_NODEJS_ORG_MIRROR NVM_DIR NVM_CD_FLAGS > /dev/null 2>&1
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
@@ -2367,17 +2420,22 @@ nvm_auto() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
NVM_AUTO_MODE='use'
|
nvm_process_parameters() {
|
||||||
if nvm_supports_source_options; then
|
local NVM_AUTO_MODE
|
||||||
while [ $# -ne 0 ]
|
NVM_AUTO_MODE='use'
|
||||||
do
|
if nvm_supports_source_options; then
|
||||||
case "$1" in
|
while [ $# -ne 0 ]
|
||||||
--install) NVM_AUTO_MODE='install' ;;
|
do
|
||||||
--no-use) NVM_AUTO_MODE='none' ;;
|
case "$1" in
|
||||||
esac
|
--install) NVM_AUTO_MODE='install' ;;
|
||||||
shift
|
--no-use) NVM_AUTO_MODE='none' ;;
|
||||||
done
|
esac
|
||||||
fi
|
shift
|
||||||
nvm_auto "$NVM_AUTO_MODE"
|
done
|
||||||
|
fi
|
||||||
|
nvm_auto "$NVM_AUTO_MODE"
|
||||||
|
}
|
||||||
|
|
||||||
|
nvm_process_parameters "$@"
|
||||||
|
|
||||||
} # this ensures the entire script is downloaded #
|
} # this ensures the entire script is downloaded #
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nvm",
|
"name": "nvm",
|
||||||
"version": "0.30.2",
|
"version": "0.31.0",
|
||||||
"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"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
export NVM_SYMLINK_CURRENT=true
|
export NVM_SYMLINK_CURRENT=true
|
||||||
. ../../nvm.sh
|
. ../../nvm.sh
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
. ../../nvm.sh
|
. ../../nvm.sh
|
||||||
|
|
||||||
|
|||||||
5
test/fast/Sourcing nvm.sh should not modify parameters of caller
Executable file
5
test/fast/Sourcing nvm.sh should not modify parameters of caller
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -- yes
|
||||||
|
. ../../nvm.sh
|
||||||
|
[ "$1" = yes ]
|
||||||
@@ -4,11 +4,18 @@ die () { echo $@ ; exit 1; }
|
|||||||
|
|
||||||
. ../../../nvm.sh
|
. ../../../nvm.sh
|
||||||
|
|
||||||
OUTPUT="$(nvm_format_version 0.1.2)"
|
INPUT="0.1.2"
|
||||||
|
OUTPUT="$(nvm_format_version "$INPUT")"
|
||||||
EXPECTED_OUTPUT="v0.1.2"
|
EXPECTED_OUTPUT="v0.1.2"
|
||||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_format_version 0.1.2 did not return $EXPECTED_OUTPUT; got $OUTPUT"
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_format_version $INPUT did not return $EXPECTED_OUTPUT; got $OUTPUT"
|
||||||
|
|
||||||
OUTPUT="$(nvm_format_version 0.1)"
|
INPUT="0.1"
|
||||||
|
OUTPUT="$(nvm_format_version "$INPUT")"
|
||||||
EXPECTED_OUTPUT="v0.1.0"
|
EXPECTED_OUTPUT="v0.1.0"
|
||||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_format_version 0.1.0 did not return $EXPECTED_OUTPUT; got $OUTPUT"
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_format_version $INPUT did not return $EXPECTED_OUTPUT; got $OUTPUT"
|
||||||
|
|
||||||
|
INPUT="1.2.3.4.5"
|
||||||
|
OUTPUT="$(nvm_format_version "$INPUT")"
|
||||||
|
EXPECTED_OUTPUT="v1.2.3"
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_format_version $INPUT did not return $EXPECTED_OUTPUT; got $OUTPUT"
|
||||||
|
|
||||||
|
|||||||
45
test/fast/Unit tests/nvm_get_minor_version
Executable file
45
test/fast/Unit tests/nvm_get_minor_version
Executable file
@@ -0,0 +1,45 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
expect () {
|
||||||
|
INPUT="$1"
|
||||||
|
EXPECTED_OUTPUT="$2"
|
||||||
|
|
||||||
|
OUTPUT="$(nvm_get_minor_version "$INPUT")"
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_get_minor_version $INPUT did not return $EXPECTED_OUTPUT; got $OUTPUT"
|
||||||
|
|
||||||
|
V_OUTPUT="$(nvm_get_minor_version "v$INPUT")"
|
||||||
|
[ "_$V_OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_get_minor_version v$INPUT did not return $EXPECTED_OUTPUT; got $V_OUTPUT"
|
||||||
|
}
|
||||||
|
|
||||||
|
fail_with () {
|
||||||
|
INPUT="$1"
|
||||||
|
EXPECTED_CODE="$2"
|
||||||
|
|
||||||
|
EXIT_CODE="$(nvm_get_minor_version "$INPUT" >/dev/null 2>&1; echo $?)"
|
||||||
|
[ "_$EXIT_CODE" = "_$EXPECTED_CODE" ] || die "nvm_get_minor_version "$INPUT" did not fail with code "$EXPECTED_CODE"; got $EXIT_CODE"
|
||||||
|
}
|
||||||
|
|
||||||
|
expect 1 1.0
|
||||||
|
expect 1. 1.0
|
||||||
|
expect 1.2 1.2
|
||||||
|
expect 1.2. 1.2
|
||||||
|
expect 1.2.3 1.2
|
||||||
|
expect 1.2.3. 1.2
|
||||||
|
expect 1.2.3.4 1.2
|
||||||
|
|
||||||
|
fail_with '' 1
|
||||||
|
fail_with '.' 2
|
||||||
|
fail_with '..' 2
|
||||||
|
fail_with v 2
|
||||||
|
fail_with .a 2
|
||||||
|
fail_with .1 2
|
||||||
|
fail_with v.1 2
|
||||||
|
fail_with a.b 2
|
||||||
|
fail_with 1.a 2
|
||||||
|
fail_with a.1 2
|
||||||
|
fail_with v1.a 2
|
||||||
|
fail_with va.1 2
|
||||||
@@ -4,6 +4,8 @@ die () { echo $@ ; exit 1; }
|
|||||||
|
|
||||||
. ../../../nvm.sh
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
nvm unalias default || die 'unable to unalias default'
|
||||||
|
|
||||||
NVM_TEST_VERSION=v0.10.7
|
NVM_TEST_VERSION=v0.10.7
|
||||||
|
|
||||||
# Remove the stuff we're clobbering.
|
# Remove the stuff we're clobbering.
|
||||||
@@ -16,3 +18,6 @@ nvm install $NVM_TEST_VERSION || die "install $NVM_TEST_VERSION failed"
|
|||||||
[ -d ../../../$NVM_TEST_VERSION ]
|
[ -d ../../../$NVM_TEST_VERSION ]
|
||||||
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION || die "'nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed"
|
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION || die "'nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed"
|
||||||
|
|
||||||
|
# ensure default is set
|
||||||
|
NVM_CURRENT_DEFAULT="$(nvm_alias default)"
|
||||||
|
[ "$NVM_CURRENT_DEFAULT" = "$NVM_TEST_VERSION" ] || die "wrong default alias: $(nvm alias)"
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ die () { echo $@ ; exit 1; }
|
|||||||
|
|
||||||
. ../../../nvm.sh
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
nvm unalias default || die 'unable to unalias default'
|
||||||
|
|
||||||
NVM_TEST_VERSION=v0.10.7
|
NVM_TEST_VERSION=v0.10.7
|
||||||
|
|
||||||
# Remove the stuff we're clobbering.
|
# Remove the stuff we're clobbering.
|
||||||
@@ -16,3 +18,6 @@ nvm install -s $NVM_TEST_VERSION || die "'nvm install -s $NVM_TEST_VERSION' fail
|
|||||||
[ -d ../../../$NVM_TEST_VERSION ]
|
[ -d ../../../$NVM_TEST_VERSION ]
|
||||||
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION || "'nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed"
|
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION || "'nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed"
|
||||||
|
|
||||||
|
# ensure default is set
|
||||||
|
NVM_CURRENT_DEFAULT="$(nvm_alias default)"
|
||||||
|
[ "$NVM_CURRENT_DEFAULT" = "$NVM_TEST_VERSION" ] || die "wrong default alias: $(nvm alias)"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
mkdir -p ../../alias
|
mkdir -p ../../alias
|
||||||
|
rm -rf ../../alias/default
|
||||||
rm -f ../../.nvmrc
|
rm -f ../../.nvmrc
|
||||||
rm -rf ../../v0.10.7
|
rm -rf ../../v0.10.7
|
||||||
rm -rf ../../v0.9.7
|
rm -rf ../../v0.9.7
|
||||||
@@ -8,5 +9,6 @@ rm -rf ../../v0.9.12
|
|||||||
|
|
||||||
. ../../nvm.sh
|
. ../../nvm.sh
|
||||||
nvm install 0.10.1 || echo >&2 'nvm install 0.10.1 failed'
|
nvm install 0.10.1 || echo >&2 'nvm install 0.10.1 failed'
|
||||||
|
nvm unalias default || 'removing default alias failed'
|
||||||
nvm unload || echo >&2 'nvm unload failed'
|
nvm unload || echo >&2 'nvm unload failed'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user