Compare commits
32 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bef3a5ce3a | ||
|
|
0cb8c9ac2f | ||
|
|
25c61594fe | ||
|
|
0a739e3fa9 | ||
|
|
c0a20f2fa3 | ||
|
|
2d78d69d4c | ||
|
|
9e17b5059c | ||
|
|
0ac2c787be | ||
|
|
99ca0de18f | ||
|
|
f196ace5dd | ||
|
|
d1a90ca15c | ||
|
|
b3178ca925 | ||
|
|
b9df3fccb4 | ||
|
|
f408d68afc | ||
|
|
fc3a30dd0e | ||
|
|
74b36b09ff | ||
|
|
080f2149ac | ||
|
|
3bd148056e | ||
|
|
5edf013127 | ||
|
|
ae908cbff6 | ||
|
|
7805492bda | ||
|
|
a1c0c34088 | ||
|
|
234b925c7a | ||
|
|
8964cb46d3 | ||
|
|
383f39ab61 | ||
|
|
052743816f | ||
|
|
0c33fd2598 | ||
|
|
c9a53fe0c7 | ||
|
|
8b25457b74 | ||
|
|
ee520abf78 | ||
|
|
b63042bd9f | ||
|
|
382c3aa85e |
16
Makefile
16
Makefile
@@ -1,10 +1,14 @@
|
|||||||
|
# Since we rely on paths relative to the makefile location, abort if make isn't being run from there.
|
||||||
|
$(if $(findstring /,$(MAKEFILE_LIST)),$(error Please only invoke this makefile from the directory it resides in))
|
||||||
# Note: With Travis CI:
|
# Note: With Travis CI:
|
||||||
# - the path to urchin is passed via the command line.
|
# - the path to urchin is passed via the command line.
|
||||||
# - the other utilties are NOT needed, so we skip the test for their existence.
|
# - the other utilities are NOT needed, so we skip the test for their existence.
|
||||||
URCHIN := urchin
|
URCHIN := urchin
|
||||||
ifeq ($(findstring /,$(URCHIN)),) # urchin path was NOT passed in.
|
ifeq ($(findstring /,$(URCHIN)),) # urchin path was NOT passed in.
|
||||||
# Add the local npm packages' bin folder to the PATH, so that `make` can find them, when invoked directly.
|
# Add the local npm packages' bin folder to the PATH, so that `make` can find them, when invoked directly.
|
||||||
export PATH := $(shell printf '%s' "$$(npm bin):$$PATH")
|
# Note that rather than using `$(npm bin)` the 'node_modules/.bin' path component is hard-coded, so that invocation works even from an environment
|
||||||
|
# where npm is (temporarily) unavailable due to having deactivated an nvm instance loaded into the calling shell in order to avoid interference with tests.
|
||||||
|
export PATH := $(shell printf '%s' "$$PWD/node_modules/.bin:$$PATH")
|
||||||
# The list of all supporting utilities, installed with `npm install`.
|
# The list of all supporting utilities, installed with `npm install`.
|
||||||
UTILS := $(URCHIN) replace semver
|
UTILS := $(URCHIN) replace semver
|
||||||
# Make sure that all required utilities can be located.
|
# Make sure that all required utilities can be located.
|
||||||
@@ -17,9 +21,6 @@ SHELLS := sh bash dash zsh # ksh (#574)
|
|||||||
# Generate 'test-<shell>' target names from specified shells.
|
# Generate 'test-<shell>' target names from specified shells.
|
||||||
# The embedded shell names are extracted on demand inside the recipes.
|
# The embedded shell names are extracted on demand inside the recipes.
|
||||||
SHELL_TARGETS := $(addprefix test-,$(SHELLS))
|
SHELL_TARGETS := $(addprefix test-,$(SHELLS))
|
||||||
# Determine if the installed Urchin version supports cross-shell testing, based on whether its usage information mentions the -s option.
|
|
||||||
HAVE_CROSS_SHELL_TESTS := $(shell PATH="$(PATH)" $(URCHIN) -h | grep -qE '(^|\s)-s\s' && echo 'yes')
|
|
||||||
NO_CROSS_SHELL_TESTS_WARNING := $(if $(HAVE_CROSS_SHELL_TESTS),,$(warning WARNING: This version of Urchin does not support cross-shell tests. All tests will run with 'sh'.))
|
|
||||||
# Define the default test suite(s). This can be overridden with `make TEST_SUITE=<...> <target>`.
|
# Define the default test suite(s). This can be overridden with `make TEST_SUITE=<...> <target>`.
|
||||||
# Test suites are the names of subfolders of './test'.
|
# Test suites are the names of subfolders of './test'.
|
||||||
TEST_SUITE := $(shell find ./test/* -type d -prune -exec basename {} \;)
|
TEST_SUITE := $(shell find ./test/* -type d -prune -exec basename {} \;)
|
||||||
@@ -41,9 +42,8 @@ list:
|
|||||||
$(SHELL_TARGETS):
|
$(SHELL_TARGETS):
|
||||||
@shell='$@'; shell=$${shell##*-}; which "$$shell" >/dev/null || { printf '\033[0;31m%s\033[0m\n' "WARNING: Cannot test with shell '$$shell': not found." >&2; exit 0; } && \
|
@shell='$@'; shell=$${shell##*-}; which "$$shell" >/dev/null || { printf '\033[0;31m%s\033[0m\n' "WARNING: Cannot test with shell '$$shell': not found." >&2; exit 0; } && \
|
||||||
printf '\n\033[0;34m%s\033[0m\n' "Running tests in $$shell"; \
|
printf '\n\033[0;34m%s\033[0m\n' "Running tests in $$shell"; \
|
||||||
[ -z "$$TRAVIS_BUILD_DIR" ] && for v in $$(export -p | awk -F'[ =]' '$$2 ~ "^NVM_" { print $$2 }'); do unset $$v; done && unset v; \
|
[ -z "$$TRAVIS_BUILD_DIR" ] && for v in $$(set | awk -F'=' '$$1 ~ "^NVM_" { print $$1 }'); do unset $$v; done && unset v; \
|
||||||
[ "$(HAVE_CROSS_SHELL_TESTS)" = 'yes' ] && targetShellOpt="-s $$shell" || targetShellOpt=; \
|
for suite in $(TEST_SUITE); do $(URCHIN) -f -s $$shell test/$$suite || exit; done
|
||||||
for suite in $(TEST_SUITE); do $(URCHIN) -f $$targetShellOpt test/$$suite || exit; done
|
|
||||||
|
|
||||||
# All-tests target: invokes the specified test suites for ALL shells defined in $(SHELLS).
|
# All-tests target: invokes the specified test suites for ALL shells defined in $(SHELLS).
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
|
|||||||
@@ -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.19.0/install.sh | bash
|
curl https://raw.githubusercontent.com/creationix/nvm/v0.21.0/install.sh | bash
|
||||||
|
|
||||||
or Wget:
|
or Wget:
|
||||||
|
|
||||||
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.19.0/install.sh | bash
|
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.21.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>
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ Often I also put in a line to use a specific version of node.
|
|||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
You can create an `.nvmrc` file containing version number in the project root directory (or any parent directory).
|
You can create an `.nvmrc` file containing version number in the project root directory (or any parent directory).
|
||||||
`nvm use`, `nvm install`, `nvm exec`, and `nvm run` will all respect an `.nvmrc` file.
|
`nvm use`, `nvm install`, `nvm exec`, `nvm run`, and `nvm which` will all respect an `.nvmrc` file when a version is not supplied.
|
||||||
|
|
||||||
To download, compile, and install the latest v0.10.x release of node, do this:
|
To download, compile, and install the latest v0.10.x release of node, do this:
|
||||||
|
|
||||||
@@ -61,6 +61,10 @@ Or, you can run any arbitrary command in a subshell with the desired version of
|
|||||||
|
|
||||||
nvm exec 0.10 node --version
|
nvm exec 0.10 node --version
|
||||||
|
|
||||||
|
You can also get the path to the executable to where it was installed:
|
||||||
|
|
||||||
|
nvm which 0.10
|
||||||
|
|
||||||
In place of a version pointer like "0.10", you can use the special default aliases "stable" and "unstable":
|
In place of a version pointer like "0.10", you can use the special default aliases "stable" and "unstable":
|
||||||
|
|
||||||
nvm install stable
|
nvm install stable
|
||||||
@@ -187,7 +191,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.19.0/install.sh
|
[2]: https://github.com/creationix/nvm/blob/v0.21.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
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ __nvm_commands ()
|
|||||||
alias unalias reinstall-packages \
|
alias unalias reinstall-packages \
|
||||||
current list ls list-remote ls-remote \
|
current list ls list-remote ls-remote \
|
||||||
clear-cache deactivate unload \
|
clear-cache deactivate unload \
|
||||||
version'
|
version which'
|
||||||
|
|
||||||
if [ ${#COMP_WORDS[@]} == 4 ]; then
|
if [ ${#COMP_WORDS[@]} == 4 ]; then
|
||||||
|
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ nvm_source() {
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
if [ "_$NVM_METHOD" = "_script" ]; then
|
if [ "_$NVM_METHOD" = "_script" ]; then
|
||||||
NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/v0.19.0/nvm.sh"
|
NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/v0.21.0/nvm.sh"
|
||||||
elif [ "_$NVM_METHOD" = "_script-nvm-exec" ]; then
|
elif [ "_$NVM_METHOD" = "_script-nvm-exec" ]; then
|
||||||
NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/v0.19.0/nvm-exec"
|
NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/v0.21.0/nvm-exec"
|
||||||
elif [ "_$NVM_METHOD" = "_git" ] || [ -z "$NVM_METHOD" ]; then
|
elif [ "_$NVM_METHOD" = "_git" ] || [ -z "$NVM_METHOD" ]; then
|
||||||
NVM_SOURCE="https://github.com/creationix/nvm.git"
|
NVM_SOURCE="https://github.com/creationix/nvm.git"
|
||||||
else
|
else
|
||||||
@@ -69,7 +69,7 @@ install_nvm_from_git() {
|
|||||||
mkdir -p "$NVM_DIR"
|
mkdir -p "$NVM_DIR"
|
||||||
git clone "$(nvm_source "git")" "$NVM_DIR"
|
git clone "$(nvm_source "git")" "$NVM_DIR"
|
||||||
fi
|
fi
|
||||||
cd "$NVM_DIR" && git checkout v0.19.0 && git branch -D master >/dev/null 2>&1
|
cd "$NVM_DIR" && git checkout --quiet v0.21.0 && git branch --quiet -D master >/dev/null 2>&1
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
79
nvm.sh
79
nvm.sh
@@ -12,6 +12,24 @@ nvm_has() {
|
|||||||
type "$1" > /dev/null 2>&1
|
type "$1" > /dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nvm_get_latest() {
|
||||||
|
local NVM_LATEST_URL
|
||||||
|
if nvm_has "curl"; then
|
||||||
|
NVM_LATEST_URL="$(curl -w "%{url_effective}\n" -L -s -S http://latest.nvm.sh -o /dev/null)"
|
||||||
|
elif nvm_has "wget"; then
|
||||||
|
NVM_LATEST_URL="$(wget http://latest.nvm.sh --server-response -O /dev/null 2>&1 | awk '/^ Location: /{DEST=$2} END{ print DEST }')"
|
||||||
|
else
|
||||||
|
>&2 echo 'nvm needs curl or wget to proceed.'
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if [ "_$NVM_LATEST_URL" = "_" ]; then
|
||||||
|
>&2 echo "http://latest.nvm.sh did not redirect to the latest release on Github"
|
||||||
|
return 2
|
||||||
|
else
|
||||||
|
echo "$NVM_LATEST_URL" | awk -F'/' '{print $NF}'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
nvm_download() {
|
nvm_download() {
|
||||||
if nvm_has "curl"; then
|
if nvm_has "curl"; then
|
||||||
curl $*
|
curl $*
|
||||||
@@ -253,11 +271,11 @@ nvm_alias() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
nvm_ls_current() {
|
nvm_ls_current() {
|
||||||
local NODE_PATH
|
local NVM_LS_CURRENT_NODE_PATH
|
||||||
NODE_PATH="$(which node 2> /dev/null)"
|
NVM_LS_CURRENT_NODE_PATH="$(which node 2> /dev/null)"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo 'none'
|
echo 'none'
|
||||||
elif nvm_tree_contains_path "$NVM_DIR" "$NODE_PATH"; then
|
elif nvm_tree_contains_path "$NVM_DIR" "$NVM_LS_CURRENT_NODE_PATH"; then
|
||||||
local VERSION
|
local VERSION
|
||||||
VERSION=`node -v 2>/dev/null`
|
VERSION=`node -v 2>/dev/null`
|
||||||
if [ "$VERSION" = "v0.6.21-pre" ]; then
|
if [ "$VERSION" = "v0.6.21-pre" ]; then
|
||||||
@@ -547,6 +565,7 @@ nvm() {
|
|||||||
echo " nvm unalias <name> Deletes the alias named <name>"
|
echo " nvm unalias <name> Deletes the alias named <name>"
|
||||||
echo " nvm reinstall-packages <version> Reinstall global \`npm\` packages contained in <version> to current version"
|
echo " nvm reinstall-packages <version> Reinstall global \`npm\` packages contained in <version> to current version"
|
||||||
echo " nvm unload Unload \`nvm\` from shell"
|
echo " nvm unload Unload \`nvm\` from shell"
|
||||||
|
echo " nvm which [<version>] Display path to installed node version. Uses .nvmrc if available"
|
||||||
echo
|
echo
|
||||||
echo "Example:"
|
echo "Example:"
|
||||||
echo " nvm install v0.10.32 Install a specific version number"
|
echo " nvm install v0.10.32 Install a specific version number"
|
||||||
@@ -790,9 +809,7 @@ nvm() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
NEWPATH="$(nvm_strip_path "$NODE_PATH" "/lib/node_modules")"
|
NEWPATH="$(nvm_strip_path "$NODE_PATH" "/lib/node_modules")"
|
||||||
if [ "$NODE_PATH" = "$NEWPATH" ]; then
|
if [ "$NODE_PATH" != "$NEWPATH" ]; then
|
||||||
echo "Could not find $NVM_DIR/*/lib/node_modules in \$NODE_PATH" >&2
|
|
||||||
else
|
|
||||||
export NODE_PATH="$NEWPATH"
|
export NODE_PATH="$NEWPATH"
|
||||||
echo "$NVM_DIR/*/lib/node_modules removed from \$NODE_PATH"
|
echo "$NVM_DIR/*/lib/node_modules removed from \$NODE_PATH"
|
||||||
fi
|
fi
|
||||||
@@ -850,13 +867,8 @@ nvm() {
|
|||||||
MANPATH=`nvm_prepend_path "$MANPATH" "$NVM_VERSION_DIR/share/man"`
|
MANPATH=`nvm_prepend_path "$MANPATH" "$NVM_VERSION_DIR/share/man"`
|
||||||
export MANPATH
|
export MANPATH
|
||||||
fi
|
fi
|
||||||
# Strip other version from NODE_PATH
|
|
||||||
NODE_PATH=`nvm_strip_path "$NODE_PATH" "/lib/node_modules"`
|
|
||||||
# Prepend current version
|
|
||||||
NODE_PATH=`nvm_prepend_path "$NODE_PATH" "$NVM_VERSION_DIR/lib/node_modules"`
|
|
||||||
export PATH
|
export PATH
|
||||||
hash -r
|
hash -r
|
||||||
export NODE_PATH
|
|
||||||
export NVM_PATH="$NVM_VERSION_DIR/lib/node"
|
export NVM_PATH="$NVM_VERSION_DIR/lib/node"
|
||||||
export NVM_BIN="$NVM_VERSION_DIR/bin"
|
export NVM_BIN="$NVM_VERSION_DIR/bin"
|
||||||
if [ "$NVM_SYMLINK_CURRENT" = true ]; then
|
if [ "$NVM_SYMLINK_CURRENT" = true ]; then
|
||||||
@@ -953,6 +965,49 @@ nvm() {
|
|||||||
"current" )
|
"current" )
|
||||||
nvm_version current
|
nvm_version current
|
||||||
;;
|
;;
|
||||||
|
"which" )
|
||||||
|
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"
|
||||||
|
fi
|
||||||
|
if [ -z "$VERSION" ]; then
|
||||||
|
nvm help
|
||||||
|
return 127
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "_$VERSION" = '_system' ]; then
|
||||||
|
if nvm_has_system_node >/dev/null 2>&1; then
|
||||||
|
local NVM_BIN
|
||||||
|
NVM_BIN="$(nvm use system >/dev/null 2>&1 && which node)"
|
||||||
|
if [ -n "$NVM_BIN" ]; then
|
||||||
|
echo "$NVM_BIN"
|
||||||
|
return
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "System version of node not found." >&2
|
||||||
|
return 127
|
||||||
|
fi
|
||||||
|
elif [ "_$VERSION" = "_∞" ]; then
|
||||||
|
echo "The alias \"$2\" leads to an infinite loop. Aborting." >&2
|
||||||
|
return 8
|
||||||
|
fi
|
||||||
|
|
||||||
|
local NVM_VERSION_DIR
|
||||||
|
NVM_VERSION_DIR="$(nvm_version_path "$VERSION")"
|
||||||
|
if [ ! -d "$NVM_VERSION_DIR" ]; then
|
||||||
|
echo "$VERSION version is not installed yet" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
echo "$NVM_VERSION_DIR/bin/node"
|
||||||
|
;;
|
||||||
"alias" )
|
"alias" )
|
||||||
mkdir -p "$NVM_DIR/alias"
|
mkdir -p "$NVM_DIR/alias"
|
||||||
if [ $# -le 2 ]; then
|
if [ $# -le 2 ]; then
|
||||||
@@ -1044,7 +1099,7 @@ nvm() {
|
|||||||
nvm_version $2
|
nvm_version $2
|
||||||
;;
|
;;
|
||||||
"--version" )
|
"--version" )
|
||||||
echo "0.19.0"
|
echo "0.21.0"
|
||||||
;;
|
;;
|
||||||
"unload" )
|
"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 > /dev/null 2>&1
|
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 > /dev/null 2>&1
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nvm",
|
"name": "nvm",
|
||||||
"version": "0.19.0",
|
"version": "0.21.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"
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
"homepage": "https://github.com/creationix/nvm",
|
"homepage": "https://github.com/creationix/nvm",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"replace": "~0.3.0",
|
"replace": "~0.3.0",
|
||||||
"semver": "~4.1.0",
|
"semver": "~4.1.1",
|
||||||
"urchin": "~0.0.4"
|
"urchin": "~0.0.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
mkdir -p ../../../v0.0.2
|
||||||
|
mkdir -p ../../../v0.0.20
|
||||||
|
mkdir -p ../../../versions/v0.12.0
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
# The result should contain only the appropriate version numbers.
|
||||||
|
|
||||||
|
nvm which 0.0.2 || die "v0.0.2 not found"
|
||||||
|
NVM_BIN="$(nvm which 0.0.2)"
|
||||||
|
[ "_$NVM_BIN" = "_$(nvm_version_path v0.0.2)/bin/node" ] \
|
||||||
|
|| die "'nvm which 0.0.2' did not contain the correct path: got '$NVM_BIN'"
|
||||||
|
|
||||||
|
nvm which 0.0.20 || die "v0.0.20 not found"
|
||||||
|
NVM_BIN="$(nvm which 0.0.20)"
|
||||||
|
[ "_$NVM_BIN" = "_$(nvm_version_path v0.0.20)/bin/node" ] \
|
||||||
|
|| die "'nvm which 0.20.0' did not contain the correct path: got '$NVM_BIN'"
|
||||||
|
|
||||||
|
nvm which 0.12.0 || die "v0.0.20 not found"
|
||||||
|
NVM_BIN="$(nvm which 0.12.0)"
|
||||||
|
[ "_$NVM_BIN" = "_$(nvm_version_path v0.12.0)/bin/node" ] \
|
||||||
|
|| die "'nvm which 0.12.0' did not contain the correct path: got '$NVM_BIN'"
|
||||||
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
nvm which nonexistent_version
|
||||||
|
[ "_$?" = "_1" ]
|
||||||
3
test/fast/Listing paths/teardown
Executable file
3
test/fast/Listing paths/teardown
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
rmdir ../../../v0.0.2 >/dev/null 2>&1
|
||||||
|
rmdir ../../../v0.0.20 >/dev/null 2>&1
|
||||||
|
rmdir ../../../v0.12.0 >/dev/null 2>&1
|
||||||
@@ -7,8 +7,11 @@ die () { echo $@ ; exit 1; }
|
|||||||
[ `expr $PATH : ".*v0.2.3/.*/bin"` = 0 ] || echo "WARNING: Unexpectedly found v0.2.3 already active" >&2
|
[ `expr $PATH : ".*v0.2.3/.*/bin"` = 0 ] || echo "WARNING: Unexpectedly found v0.2.3 already active" >&2
|
||||||
|
|
||||||
. ../../nvm.sh
|
. ../../nvm.sh
|
||||||
nvm use v0.2.3 &&
|
nvm use v0.2.3 || die "Failed to activate v0.2.3"
|
||||||
[ `expr $PATH : ".*v0.2.3/.*/bin"` != 0 ] && [ `expr $NODE_PATH : ".*v0.2.3/.*/lib/node_modules"` != 0 ] || die "Failed to activate v0.2.3"
|
[ `expr "$PATH" : ".*v0.2.3/.*/bin"` != 0 ] || die "PATH not set up properly"
|
||||||
|
[ `expr "$NODE_PATH" : ".*v0.2.3/.*/lib/node_modules"` = 0 ] || die "NODE_PATH should not contain (npm root -g)"
|
||||||
|
# ^ note: NODE_PATH should not contain `npm root -g` since globals should not be requireable
|
||||||
|
|
||||||
nvm deactivate &&
|
nvm deactivate || die "Failed to deactivate v0.2.3"
|
||||||
[ `expr $PATH : ".*v0.2.3/.*/bin"` = 0 ] && [ `expr $NODE_PATH : ".*v0.2.3/.*/lib/node_modules"` = 0 ] || die "Failed to deactivate v0.2.3"
|
[ `expr "$PATH" : ".*v0.2.3/.*/bin"` = 0 ] || die "PATH not cleaned properly"
|
||||||
|
[ `expr "$NODE_PATH" : ".*v0.2.3/.*/lib/node_modules"` = 0 ] || die "NODE_PATH not cleaned properly"
|
||||||
|
|||||||
20
test/fast/Unit tests/nvm_get_latest missing curl or wget
Executable file
20
test/fast/Unit tests/nvm_get_latest missing curl or wget
Executable file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; cleanup ; exit 1; }
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
unset -f nvm_has
|
||||||
|
}
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
nvm_has() { return 1 ; }
|
||||||
|
|
||||||
|
OUTPUT="$(nvm_get_latest 2>&1)"
|
||||||
|
EXIT_CODE="$(nvm_get_latest >/dev/null 2>&1 ; echo $?)"
|
||||||
|
[ "_$OUTPUT" = "_nvm needs curl or wget to proceed." ] \
|
||||||
|
|| die "no curl/wget did not report correct error message, got '$OUTPUT'"
|
||||||
|
[ "_$EXIT_CODE" = "_1" ] \
|
||||||
|
|| die "no curl/wget did not exit with code 1, got $EXIT_CODE"
|
||||||
|
|
||||||
|
cleanup
|
||||||
117
test/installation/nvm_get_latest/nvm_get_latest
Executable file
117
test/installation/nvm_get_latest/nvm_get_latest
Executable file
@@ -0,0 +1,117 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; cleanup ; exit 1; }
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
unset -f curl wget nvm_has
|
||||||
|
}
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
EXPECTED_VERSION="v12.3.456"
|
||||||
|
URL="https://github.com/creationix/nvm/releases/tag/$EXPECTED_VERSION"
|
||||||
|
EXPECTED_CURL_ARGS="-w %{url_effective}\n -L -s -S http://latest.nvm.sh -o /dev/null"
|
||||||
|
EXPECTED_WGET_ARGS="http://latest.nvm.sh --server-response -O /dev/null"
|
||||||
|
|
||||||
|
curl() {
|
||||||
|
if [ "_$*" != "_$EXPECTED_CURL_ARGS" ]; then
|
||||||
|
echo 2>& "expected args ($EXPECTED_CURL_ARGS), got ($*)"
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
echo $URL
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
wget() {
|
||||||
|
if [ "_$*" != "_$EXPECTED_WGET_ARGS" ]; then
|
||||||
|
echo 2>& "expected args ($EXPECTED_WGET_ARGS), got ($*)"
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
local WGET_CONTENTS
|
||||||
|
WGET_CONTENTS="
|
||||||
|
--2014-12-21 18:11:14-- http://latest.nvm.sh/
|
||||||
|
Resolving latest.nvm.sh... 50.31.209.229
|
||||||
|
Connecting to latest.nvm.sh|50.31.209.229|:80... connected.
|
||||||
|
HTTP request sent, awaiting response...
|
||||||
|
HTTP/1.1 301 Moved Permanently
|
||||||
|
Location: https://github.com/creationix/nvm/releases/latest
|
||||||
|
Content-Type: text/html; charset=utf-8
|
||||||
|
Content-Length: 84
|
||||||
|
Date: Mon, 22 Dec 2014 02:11:15 GMT
|
||||||
|
Location: https://github.com/creationix/nvm/releases/latest [following]
|
||||||
|
--2014-12-21 18:11:15-- https://github.com/creationix/nvm/releases/latest
|
||||||
|
Resolving github.com... 192.30.252.130
|
||||||
|
Connecting to github.com|192.30.252.130|:443... connected.
|
||||||
|
HTTP request sent, awaiting response...
|
||||||
|
HTTP/1.1 302 Found
|
||||||
|
Server: GitHub.com
|
||||||
|
Date: Mon, 22 Dec 2014 02:11:15 GMT
|
||||||
|
Content-Type: text/html; charset=utf-8
|
||||||
|
Transfer-Encoding: chunked
|
||||||
|
Status: 302 Found
|
||||||
|
X-XSS-Protection: 1; mode=block
|
||||||
|
X-Frame-Options: deny
|
||||||
|
Content-Security-Policy: default-src *; script-src assets-cdn.github.com collector-cdn.github.com; object-src assets-cdn.github.com; style-src 'self' 'unsafe-inline' 'unsafe-eval' assets-cdn.github.com; img-src 'self' data: assets-cdn.github.com identicons.github.com www.google-analytics.com collector.githubapp.com *.githubusercontent.com *.gravatar.com *.wp.com; media-src 'none'; frame-src 'self' render.githubusercontent.com gist.github.com www.youtube.com player.vimeo.com checkout.paypal.com; font-src assets-cdn.github.com; connect-src 'self' ghconduit.com:25035 live.github.com uploads.github.com www.google-analytics.com s3.amazonaws.com
|
||||||
|
Cache-Control: no-cache
|
||||||
|
Vary: X-PJAX
|
||||||
|
Location: $URL
|
||||||
|
X-UA-Compatible: IE=Edge,chrome=1
|
||||||
|
Set-Cookie: logged_in=no; domain=.github.com; path=/; expires=Fri, 22-Dec-2034 02:11:15 GMT; secure; HttpOnly
|
||||||
|
Set-Cookie: _gh_sess=eyJzZXNzaW9uX2lkIjoiNTMzNGNjZWUxM2VhZjNhN2M3MzIwZWUxNGYwNzhmNDkiLCJzcHlfcmVwbyI6ImNyZWF0aW9uaXgvbnZtIiwic3B5X3JlcG9fYXQiOjE0MTkyMTQyNzV9--e2fa4cf5305d61aa58c0e0bf21fdb335a9660dcf; path=/; secure; HttpOnly
|
||||||
|
X-Request-Id: 4b99bf200157dd845f76ab83e4093acc
|
||||||
|
X-Runtime: 0.030872
|
||||||
|
X-Rack-Cache: miss
|
||||||
|
X-GitHub-Request-Id: 45B56780:3913:880EF6:54977DC3
|
||||||
|
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
|
||||||
|
X-Content-Type-Options: nosniff
|
||||||
|
Vary: Accept-Encoding
|
||||||
|
X-Served-By: ef97014f01ea59c1ef337fe51a4d0331
|
||||||
|
Location: $URL [following]
|
||||||
|
--2014-12-21 18:11:15-- $URL
|
||||||
|
Reusing existing connection to github.com:443.
|
||||||
|
HTTP request sent, awaiting response...
|
||||||
|
HTTP/1.1 200 OK
|
||||||
|
Server: GitHub.com
|
||||||
|
Date: Mon, 22 Dec 2014 02:11:15 GMT
|
||||||
|
Content-Type: text/html; charset=utf-8
|
||||||
|
Transfer-Encoding: chunked
|
||||||
|
Status: 200 OK
|
||||||
|
X-XSS-Protection: 1; mode=block
|
||||||
|
X-Frame-Options: deny
|
||||||
|
Content-Security-Policy: default-src *; script-src assets-cdn.github.com collector-cdn.github.com; object-src assets-cdn.github.com; style-src 'self' 'unsafe-inline' 'unsafe-eval' assets-cdn.github.com; img-src 'self' data: assets-cdn.github.com identicons.github.com www.google-analytics.com collector.githubapp.com *.githubusercontent.com *.gravatar.com *.wp.com; media-src 'none'; frame-src 'self' render.githubusercontent.com gist.github.com www.youtube.com player.vimeo.com checkout.paypal.com; font-src assets-cdn.github.com; connect-src 'self' ghconduit.com:25035 live.github.com uploads.github.com www.google-analytics.com s3.amazonaws.com
|
||||||
|
Cache-Control: no-cache, private
|
||||||
|
Vary: X-PJAX
|
||||||
|
X-UA-Compatible: IE=Edge,chrome=1
|
||||||
|
Set-Cookie: _gh_sess=eyJzZXNzaW9uX2lkIjoiNTMzNGNjZWUxM2VhZjNhN2M3MzIwZWUxNGYwNzhmNDkiLCJzcHlfcmVwbyI6ImNyZWF0aW9uaXgvbnZtIiwic3B5X3JlcG9fYXQiOjE0MTkyMTQyNzUsIl9jc3JmX3Rva2VuIjoiemZTVDNIRGo0QzF0dzkyNXp6NFBRdGJVbTl4NSsxTGo1cngwVFQ3NDVwdz0ifQ%3D%3D--b72bfd5241907dcf557b226e74351ff39f0e9ede; path=/; secure; HttpOnly
|
||||||
|
X-Request-Id: 305b0d158bf8c0b3fa488a33d7687091
|
||||||
|
X-Runtime: 0.038544
|
||||||
|
X-Rack-Cache: miss
|
||||||
|
X-GitHub-Request-Id: 45B56780:3913:880F19:54977DC3
|
||||||
|
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
|
||||||
|
X-Content-Type-Options: nosniff
|
||||||
|
Vary: Accept-Encoding
|
||||||
|
X-Served-By: 926b734ea1992f8ee1f88ab967a93dac
|
||||||
|
Length: unspecified [text/html]
|
||||||
|
Saving to: ‘/dev/null’
|
||||||
|
|
||||||
|
0K .......... ......... 225K=0.09s
|
||||||
|
|
||||||
|
2014-12-21 18:11:15 (225 KB/s) - ‘/dev/null’ saved [20298]
|
||||||
|
|
||||||
|
"
|
||||||
|
"$WGET_CONTENTS" | while read line
|
||||||
|
do
|
||||||
|
2>& echo "$line"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
OUTPUT="$(nvm_get_latest)"
|
||||||
|
EXIT_CODE="$(nvm_get_latest >/dev/null 2>&1 ; echo $?)"
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_VERSION" ] \
|
||||||
|
|| die "success path did not return version '$EXPECTED_VERSION', got '$OUTPUT'"
|
||||||
|
[ "_$EXIT_CODE" = "_0" ] \
|
||||||
|
|| die "success path did not exit with code 0, got $EXIT_CODE"
|
||||||
|
|
||||||
|
|
||||||
|
cleanup
|
||||||
|
|
||||||
26
test/installation/nvm_get_latest/nvm_get_latest failed redirect
Executable file
26
test/installation/nvm_get_latest/nvm_get_latest failed redirect
Executable file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; cleanup ; exit 1; }
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
unset -f curl wget
|
||||||
|
}
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
curl() {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
wget() {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
OUTPUT="$(nvm_get_latest 2>&1)"
|
||||||
|
EXIT_CODE="$(nvm_get_latest >/dev/null 2>&1 ; echo $?)"
|
||||||
|
[ "_$OUTPUT" = "_http://latest.nvm.sh did not redirect to the latest release on Github" ] \
|
||||||
|
|| die "failed redirect did not report correct error message, got '$OUTPUT'"
|
||||||
|
[ "_$EXIT_CODE" = "_2" ] \
|
||||||
|
|| die "failed redirect did not exit with code 2, got $EXIT_CODE"
|
||||||
|
|
||||||
|
cleanup
|
||||||
|
|
||||||
Reference in New Issue
Block a user