Compare commits
90 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
838d72688f | ||
|
|
8ee6f30352 | ||
|
|
1458de7293 | ||
|
|
a1def71062 | ||
|
|
eb81fba8f7 | ||
|
|
7496a24bd6 | ||
|
|
c64a0343af | ||
|
|
643365a948 | ||
|
|
6e894520ec | ||
|
|
9e389eb9fe | ||
|
|
151efc32f5 | ||
|
|
bda1d2ec29 | ||
|
|
e3528b0d9e | ||
|
|
014a44e154 | ||
|
|
c9215a127f | ||
|
|
c92effc6da | ||
|
|
1e2a7a8de4 | ||
|
|
d4caf9fb67 | ||
|
|
0ef20199dc | ||
|
|
0d898b0aa4 | ||
|
|
0181821b51 | ||
|
|
f34fef96d8 | ||
|
|
26ee4aafc0 | ||
|
|
8746d63041 | ||
|
|
b7e2d7d24d | ||
|
|
58ffa407c2 | ||
|
|
49abc9ce02 | ||
|
|
15876280f7 | ||
|
|
9f653cc196 | ||
|
|
543b86c060 | ||
|
|
ba01993ea6 | ||
|
|
31e7d5b36a | ||
|
|
17c68075e8 | ||
|
|
3fcff872af | ||
|
|
c07838fcc0 | ||
|
|
fe1ed37520 | ||
|
|
ae1c488fe1 | ||
|
|
d9662f138f | ||
|
|
071323847c | ||
|
|
b7a93be02e | ||
|
|
3543cd5d2f | ||
|
|
d7035c5e61 | ||
|
|
1f679fc055 | ||
|
|
c37dbbecb4 | ||
|
|
f81b6d6b7b | ||
|
|
d57f7ea54a | ||
|
|
759f86f946 | ||
|
|
60c2f3705e | ||
|
|
657192dd27 | ||
|
|
98e40a8da5 | ||
|
|
2da44f90d2 | ||
|
|
88a50780fc | ||
|
|
9419794b19 | ||
|
|
b4151e1446 | ||
|
|
f2d31b0458 | ||
|
|
0b41352210 | ||
|
|
be5e8de0c8 | ||
|
|
3ef937a64e | ||
|
|
a21b2e6962 | ||
|
|
cc090f4476 | ||
|
|
c31b072145 | ||
|
|
7bce6c6c68 | ||
|
|
fb2f1ac627 | ||
|
|
bc3840b6f3 | ||
|
|
6b8fd19d76 | ||
|
|
c1ef31df53 | ||
|
|
3b67b3b9bb | ||
|
|
83466446ce | ||
|
|
3214caa4ec | ||
|
|
67f2ee82ca | ||
|
|
1f13f15620 | ||
|
|
fe044c5e3b | ||
|
|
3cfa1ed4e1 | ||
|
|
d78722b284 | ||
|
|
4c475b2767 | ||
|
|
a539cba11e | ||
|
|
472ba5fc46 | ||
|
|
96c96ec714 | ||
|
|
475b8bd6b4 | ||
|
|
5e805905ca | ||
|
|
2dec01da9c | ||
|
|
63672641a5 | ||
|
|
94bba31de3 | ||
|
|
f70530ef18 | ||
|
|
ec33e8b720 | ||
|
|
a4f89c6223 | ||
|
|
517817f1a3 | ||
|
|
a6f5eff0f3 | ||
|
|
0aac462b15 | ||
|
|
bb2fe618cb |
@@ -10,11 +10,7 @@ install:
|
|||||||
script:
|
script:
|
||||||
- NVM_DIR=$TRAVIS_BUILD_DIR make TEST_SUITE=$TEST_SUITE URCHIN=/tmp/urchin/package/urchin test-$SHELL
|
- NVM_DIR=$TRAVIS_BUILD_DIR make TEST_SUITE=$TEST_SUITE URCHIN=/tmp/urchin/package/urchin test-$SHELL
|
||||||
env:
|
env:
|
||||||
- SHELL=sh TEST_SUITE=install_script
|
|
||||||
- SHELL=dash TEST_SUITE=install_script
|
|
||||||
- SHELL=bash TEST_SUITE=install_script
|
- SHELL=bash TEST_SUITE=install_script
|
||||||
- SHELL=zsh TEST_SUITE=install_script
|
|
||||||
# - SHELL=ksh TEST_SUITE=install_script
|
|
||||||
- SHELL=sh TEST_SUITE=fast
|
- SHELL=sh TEST_SUITE=fast
|
||||||
- SHELL=dash TEST_SUITE=fast
|
- SHELL=dash TEST_SUITE=fast
|
||||||
- SHELL=bash TEST_SUITE=fast
|
- SHELL=bash TEST_SUITE=fast
|
||||||
|
|||||||
@@ -4,23 +4,22 @@
|
|||||||
|
|
||||||
First you'll need to make sure your system has a c++ compiler. For OSX, XCode will work, for Ubuntu, the build-essential and libssl-dev packages work.
|
First you'll need to make sure your system has a c++ compiler. For OSX, XCode will work, for Ubuntu, the build-essential and libssl-dev packages work.
|
||||||
|
|
||||||
Note: `nvm` does not support Windows (see [#284](https://github.com/creationix/nvm/issues/284)). Two alternatives exist, which are not supported nor developed by us:
|
Note: `nvm` does not support Windows (see [#284](https://github.com/creationix/nvm/issues/284)). Two alternatives exist, which are neither supported nor developed by us:
|
||||||
- [nvmw](https://github.com/hakobera/nvmw)
|
- [nvmw](https://github.com/hakobera/nvmw)
|
||||||
- [nvm-windows](https://github.com/coreybutler/nvm-windows)
|
- [nvm-windows](https://github.com/coreybutler/nvm-windows)
|
||||||
|
|
||||||
Note: `nvm` does not support [Fish] either (see [#303](https://github.com/creationix/nvm/issues/303)). Two alternatives exist, which are not supported nor developed by us:
|
Note: `nvm` does not support [Fish] either (see [#303](https://github.com/creationix/nvm/issues/303)). An alternative exists, which is neither supported nor developed by us:
|
||||||
- [nvm-fish-wrapper](https://github.com/passcod/nvm-fish-wrapper)
|
- [bass](https://github.com/edc/bass) allows to use utilities written for Bash in fish shell
|
||||||
- [nvm-fish](https://github.com/Alex7Kom/nvm-fish) (does not support iojs)
|
|
||||||
|
|
||||||
### Install script
|
### Install script
|
||||||
|
|
||||||
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.25.0/install.sh | bash
|
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.27.0/install.sh | bash
|
||||||
|
|
||||||
or Wget:
|
or Wget:
|
||||||
|
|
||||||
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.25.0/install.sh | bash
|
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.27.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>
|
||||||
|
|
||||||
@@ -76,10 +75,27 @@ 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 a new version of Node.js and migrate npm packages from a previous version:
|
||||||
|
|
||||||
|
nvm install node --reinstall-packages-from=node
|
||||||
|
|
||||||
|
This will first use "nvm version node" to identify the current version you're migrating packages from. Then it resolves the new version to install from the remote server and installs it. Lastly, it runs "nvm reinstall-packages" to reinstall the npm packages from your prior version of Node to the new one.
|
||||||
|
|
||||||
|
You can also install and migrate npm packages from specific versions of Node like this:
|
||||||
|
|
||||||
|
nvm install v0.10.40 --reinstall-packages-from=0.10.39
|
||||||
|
nvm install v0.12.7 --reinstall-packages-from=0.12.6
|
||||||
|
|
||||||
If you want to install [io.js](https://github.com/iojs/io.js/):
|
If you want to install [io.js](https://github.com/iojs/io.js/):
|
||||||
|
|
||||||
nvm install iojs
|
nvm install iojs
|
||||||
|
|
||||||
|
If you want to install a new version of io.js and migrate npm packages from a previous version:
|
||||||
|
|
||||||
|
nvm install iojs --reinstall-packages-from=iojs
|
||||||
|
|
||||||
|
The same guidelines mentioned for migrating npm packages in Node.js are applicable to io.js.
|
||||||
|
|
||||||
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
|
||||||
@@ -220,7 +236,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.25.0/install.sh
|
[2]: https://github.com/creationix/nvm/blob/v0.27.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
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ __nvm_aliases ()
|
|||||||
declare aliases
|
declare aliases
|
||||||
aliases=""
|
aliases=""
|
||||||
if [ -d $NVM_DIR/alias ]; then
|
if [ -d $NVM_DIR/alias ]; then
|
||||||
aliases="`cd $NVM_DIR/alias && ls`"
|
aliases="`cd $NVM_DIR/alias && command ls`"
|
||||||
fi
|
fi
|
||||||
echo "${aliases}"
|
echo "${aliases}"
|
||||||
}
|
}
|
||||||
|
|||||||
52
install.sh
52
install.sh
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
{ # this ensures the entire script is downloaded #
|
||||||
|
|
||||||
nvm_has() {
|
nvm_has() {
|
||||||
type "$1" > /dev/null 2>&1
|
type "$1" > /dev/null 2>&1
|
||||||
}
|
}
|
||||||
@@ -11,7 +13,7 @@ if [ -z "$NVM_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
nvm_latest_version() {
|
nvm_latest_version() {
|
||||||
echo "v0.25.0"
|
echo "v0.27.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -42,7 +44,7 @@ nvm_source() {
|
|||||||
|
|
||||||
nvm_download() {
|
nvm_download() {
|
||||||
if nvm_has "curl"; then
|
if nvm_has "curl"; then
|
||||||
curl $*
|
curl -q $*
|
||||||
elif nvm_has "wget"; then
|
elif nvm_has "wget"; then
|
||||||
# Emulate curl with wget
|
# Emulate curl with wget
|
||||||
ARGS=$(echo "$*" | command sed -e 's/--progress-bar /--progress=bar /' \
|
ARGS=$(echo "$*" | command sed -e 's/--progress-bar /--progress=bar /' \
|
||||||
@@ -115,16 +117,38 @@ install_nvm_as_script() {
|
|||||||
# Otherwise, an empty string is returned
|
# Otherwise, an empty string is returned
|
||||||
#
|
#
|
||||||
nvm_detect_profile() {
|
nvm_detect_profile() {
|
||||||
if [ -f "$PROFILE" ]; then
|
|
||||||
echo "$PROFILE"
|
local DETECTED_PROFILE
|
||||||
elif [ -f "$HOME/.bashrc" ]; then
|
DETECTED_PROFILE=''
|
||||||
echo "$HOME/.bashrc"
|
local SHELLTYPE
|
||||||
elif [ -f "$HOME/.bash_profile" ]; then
|
SHELLTYPE="$(basename /$SHELL)"
|
||||||
echo "$HOME/.bash_profile"
|
|
||||||
elif [ -f "$HOME/.zshrc" ]; then
|
if [ $SHELLTYPE = "bash" ]; then
|
||||||
echo "$HOME/.zshrc"
|
if [ -f "$HOME/.bashrc" ]; then
|
||||||
elif [ -f "$HOME/.profile" ]; then
|
DETECTED_PROFILE="$HOME/.bashrc"
|
||||||
echo "$HOME/.profile"
|
elif [ -f "$HOME/.bash_profile" ]; then
|
||||||
|
DETECTED_PROFILE="$HOME/.bash_profile"
|
||||||
|
fi
|
||||||
|
elif [ $SHELLTYPE = "zsh" ]; then
|
||||||
|
DETECTED_PROFILE="$HOME/.zshrc"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z $DETECTED_PROFILE ]; then
|
||||||
|
if [ -f "$PROFILE" ]; then
|
||||||
|
DETECTED_PROFILE="$PROFILE"
|
||||||
|
elif [ -f "$HOME/.profile" ]; then
|
||||||
|
DETECTED_PROFILE="$HOME/.profile"
|
||||||
|
elif [ -f "$HOME/.bashrc" ]; then
|
||||||
|
DETECTED_PROFILE="$HOME/.bashrc"
|
||||||
|
elif [ -f "$HOME/.bash_profile" ]; then
|
||||||
|
DETECTED_PROFILE="$HOME/.bash_profile"
|
||||||
|
elif [ -f "$HOME/.zshrc" ]; then
|
||||||
|
DETECTED_PROFILE="$HOME/.zshrc"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -z $DETECTED_PROFILE ]; then
|
||||||
|
echo "$DETECTED_PROFILE"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,7 +240,7 @@ nvm_do_install() {
|
|||||||
printf "$SOURCE_STR"
|
printf "$SOURCE_STR"
|
||||||
echo
|
echo
|
||||||
else
|
else
|
||||||
if ! grep -qc 'nvm.sh' "$NVM_PROFILE"; then
|
if ! command grep -qc '/nvm.sh' "$NVM_PROFILE"; then
|
||||||
echo "=> Appending source string to $NVM_PROFILE"
|
echo "=> Appending source string to $NVM_PROFILE"
|
||||||
printf "$SOURCE_STR\n" >> "$NVM_PROFILE"
|
printf "$SOURCE_STR\n" >> "$NVM_PROFILE"
|
||||||
else
|
else
|
||||||
@@ -241,3 +265,5 @@ nvm_reset() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[ "_$NVM_ENV" = "_testing" ] || nvm_do_install
|
[ "_$NVM_ENV" = "_testing" ] || nvm_do_install
|
||||||
|
|
||||||
|
} # this ensures the entire script is downloaded #
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nvm",
|
"name": "nvm",
|
||||||
"version": "0.25.0",
|
"version": "0.27.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.3.3",
|
"semver": "^5.0.1",
|
||||||
"urchin": "^0.0.5"
|
"urchin": "^0.0.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ 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 || die "Failed to activate v0.2.3"
|
nvm use --delete-prefix v0.2.3 || die "Failed to activate v0.2.3"
|
||||||
[ `expr "$PATH" : ".*v0.2.3/.*/bin"` != 0 ] || die "PATH not set up properly"
|
[ `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)"
|
[ `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
|
# ^ note: NODE_PATH should not contain `npm root -g` since globals should not be requireable
|
||||||
|
|||||||
@@ -18,5 +18,13 @@ EXPECTED_OUTPUT='The alias "foo" leads to an infinite loop. Aborting.'
|
|||||||
EXIT_CODE="$(nvm use foo 2>/dev/null ; echo $?)"
|
EXIT_CODE="$(nvm use foo 2>/dev/null ; echo $?)"
|
||||||
[ "_$EXIT_CODE" = "_8" ] || die "Expected exit code 8; got $EXIT_CODE"
|
[ "_$EXIT_CODE" = "_8" ] || die "Expected exit code 8; got $EXIT_CODE"
|
||||||
|
|
||||||
|
OUTPUT="$(nvm use --silent foo 2>&1)"
|
||||||
|
EXPECTED_OUTPUT=''
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|
||||||
|
|| die "'nvm use --silent foo' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||||
|
|
||||||
|
EXIT_CODE="$(nvm use --silent foo 2>/dev/null ; echo $?)"
|
||||||
|
[ "_$EXIT_CODE" = "_8" ] || die "Expected exit code 8 from 'nvm use --silent foo'; got $EXIT_CODE"
|
||||||
|
|
||||||
cleanup;
|
cleanup;
|
||||||
|
|
||||||
|
|||||||
@@ -18,5 +18,21 @@ EXPECTED_OUTPUT='The alias "foo" leads to an infinite loop. Aborting.'
|
|||||||
EXIT_CODE="$(nvm use foo 2>/dev/null ; echo $?)"
|
EXIT_CODE="$(nvm use foo 2>/dev/null ; echo $?)"
|
||||||
[ "_$EXIT_CODE" = "_8" ] || die "Expected exit code 8; got $EXIT_CODE"
|
[ "_$EXIT_CODE" = "_8" ] || die "Expected exit code 8; got $EXIT_CODE"
|
||||||
|
|
||||||
|
OUTPUT="$(nvm use --silent foo 2>&1)"
|
||||||
|
EXPECTED_OUTPUT=''
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|
||||||
|
|| die "'nvm use --silent foo' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||||
|
|
||||||
|
OUTPUT="$(nvm use foo --silent 2>&1)"
|
||||||
|
EXPECTED_OUTPUT=''
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|
||||||
|
|| die "'nvm use foo --silent' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||||
|
|
||||||
|
EXIT_CODE="$(nvm use --silent foo 2>/dev/null ; echo $?)"
|
||||||
|
[ "_$EXIT_CODE" = "_8" ] || die "Expected exit code 8 from 'nvm use --silent foo'; got $EXIT_CODE"
|
||||||
|
|
||||||
|
EXIT_CODE="$(nvm use foo --silent 2>/dev/null ; echo $?)"
|
||||||
|
[ "_$EXIT_CODE" = "_8" ] || die "Expected exit code 8 from 'nvm use foo --silent'; got $EXIT_CODE"
|
||||||
|
|
||||||
cleanup;
|
cleanup;
|
||||||
|
|
||||||
|
|||||||
@@ -8,10 +8,15 @@ nvm_has_system_node() { return 0; }
|
|||||||
nvm_print_npm_version() { return ' (npm v1.2.3)'; }
|
nvm_print_npm_version() { return ' (npm v1.2.3)'; }
|
||||||
EXPECTED_OUTPUT="Now using system version of node: $(node -v)$(nvm_print_npm_version)"
|
EXPECTED_OUTPUT="Now using system version of node: $(node -v)$(nvm_print_npm_version)"
|
||||||
[ "$(nvm use system 2>&1 | tail -n1)" = "$EXPECTED_OUTPUT" ] || die "Could not use system version of node"
|
[ "$(nvm use system 2>&1 | tail -n1)" = "$EXPECTED_OUTPUT" ] || die "Could not use system version of node"
|
||||||
|
EXPECTED_OUTPUT=""
|
||||||
|
[ "$(nvm use --silent system 2>&1 | tail -n1)" = "$EXPECTED_OUTPUT" ] || die "Could not use system version of node or --silent was not silent"
|
||||||
|
|
||||||
nvm_has_system_node() { return 1; }
|
nvm_has_system_node() { return 1; }
|
||||||
nvm_print_npm_version() { return ''; }
|
nvm_print_npm_version() { return ''; }
|
||||||
EXPECTED_OUTPUT="System version of node not found."
|
EXPECTED_OUTPUT="System version of node not found."
|
||||||
[ "$(nvm use system 2>&1 | tail -n1)" = "$EXPECTED_OUTPUT" ] || die "Did not report error, system node not found"
|
[ "$(nvm use system 2>&1 | tail -n1)" = "$EXPECTED_OUTPUT" ] || die "Did not report error, system node not found"
|
||||||
nvm use system 2>&1 > /dev/null || [ $? -eq 127 ] || die "Did not return error code, system node not found"
|
nvm use system 2>&1 > /dev/null || [ $? -eq 127 ] || die "Did not return error code, system node not found"
|
||||||
|
EXPECTED_OUTPUT=""
|
||||||
|
[ "$(nvm use --silent system 2>&1 | tail -n1)" = "$EXPECTED_OUTPUT" ] || die "Did not report error, system node not found or --silent was not silent"
|
||||||
|
nvm use --silent system 2>&1 > /dev/null || [ $? -eq 127 ] || die "Did not return error code, system node not found or --silent was not silent"
|
||||||
|
|
||||||
|
|||||||
74
test/fast/Unit tests/nvm_die_on_prefix
Executable file
74
test/fast/Unit tests/nvm_die_on_prefix
Executable file
@@ -0,0 +1,74 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cleanup () {
|
||||||
|
alias nvm_has='\nvm_has'
|
||||||
|
alias npm='\npm'
|
||||||
|
unset -f nvm_has npm
|
||||||
|
}
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
OUTPUT="$(nvm_die_on_prefix 2>&1)"
|
||||||
|
EXPECTED_OUTPUT="First argument \"delete the prefix\" must be zero or one"
|
||||||
|
EXIT_CODE="$(nvm_die_on_prefix >/dev/null 2>&1; echo $?)"
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_die_on_prefix' did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||||
|
[ "_$EXIT_CODE" = "_1" ] || die "'nvm_die_on_prefix' did not exit with 1; got "$EXIT_CODE""
|
||||||
|
|
||||||
|
OUTPUT="$(nvm_die_on_prefix 2 2>&1)"
|
||||||
|
EXPECTED_OUTPUT="First argument \"delete the prefix\" must be zero or one"
|
||||||
|
EXIT_CODE="$(nvm_die_on_prefix 2 >/dev/null 2>&1; echo $?)"
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_die_on_prefix 2' did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||||
|
[ "_$EXIT_CODE" = "_1" ] || die "'nvm_die_on_prefix' did not exit with 1; got "$EXIT_CODE""
|
||||||
|
|
||||||
|
OUTPUT="$(nvm_die_on_prefix 0 2>&1)"
|
||||||
|
EXPECTED_OUTPUT="Second argument \"nvm command\" must be nonempty"
|
||||||
|
EXIT_CODE="$(nvm_die_on_prefix 0 >/dev/null 2>&1; echo $?)"
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_die_on_prefix 0' did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||||
|
[ "_$EXIT_CODE" = "_2" ] || die "'nvm_die_on_prefix 0' did not exit with 2; got '$EXIT_CODE'"
|
||||||
|
|
||||||
|
nvm_has() { return 1; } # ie, npm is not installed
|
||||||
|
OUTPUT="$(nvm_die_on_prefix 0 foo 2>&1)"
|
||||||
|
[ -z "$OUTPUT" ] || die "nvm_die_on_prefix was not a noop when nvm_has returns 1, got '$OUTPUT'"
|
||||||
|
|
||||||
|
nvm_has() { return 0; }
|
||||||
|
|
||||||
|
npm() {
|
||||||
|
local args
|
||||||
|
args="$@"
|
||||||
|
if [ "_$args" = "_config get prefix" ]; then
|
||||||
|
echo "$(nvm_version_dir new)/good prefix"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
OUTPUT="$(nvm_die_on_prefix 0 foo 2>&1)"
|
||||||
|
[ -z "$OUTPUT" ] || die "'nvm_die_on_prefix' was not a noop when prefix is good; got '$OUTPUT'"
|
||||||
|
|
||||||
|
OUTPUT="$(PREFIX=bar nvm_die_on_prefix 0 foo 2>&1)"
|
||||||
|
EXPECTED_OUTPUT='nvm is not compatible with the "PREFIX" environment variable: currently set to "bar"
|
||||||
|
Run `unset PREFIX` to unset it.'
|
||||||
|
EXIT_CODE="$(PREFIX=bar nvm_die_on_prefix 0 foo >/dev/null 2>&1; echo $?)"
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'PREFIX=bar nvm_die_on_prefix 0 foo' did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||||
|
[ "_$EXIT_CODE" = "_3" ] || die "'PREFIX=bar nvm_die_on_prefix 0 foo' did not exit with 3; got '$EXIT_CODE'"
|
||||||
|
|
||||||
|
OUTPUT="$(NPM_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo 2>&1)"
|
||||||
|
EXPECTED_OUTPUT='nvm is not compatible with the "NPM_CONFIG_PREFIX" environment variable: currently set to "bar"
|
||||||
|
Run `unset NPM_CONFIG_PREFIX` to unset it.'
|
||||||
|
EXIT_CODE="$(NPM_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo >/dev/null 2>&1; echo $?)"
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'NPM_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo' did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||||
|
[ "_$EXIT_CODE" = "_4" ] || die "'NPM_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo' did not exit with 4; got '$EXIT_CODE'"
|
||||||
|
|
||||||
|
npm() {
|
||||||
|
local args
|
||||||
|
args="$@"
|
||||||
|
if [ "_$args" = "_config get prefix" ]; then
|
||||||
|
echo "./bad prefix"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
OUTPUT="$(nvm_die_on_prefix 0 foo 2>&1)"
|
||||||
|
EXPECTED_OUTPUT="nvm is not compatible with the npm config \"prefix\" option: currently set to \"./bad prefix\"
|
||||||
|
Run \`npm config delete prefix\` or \`foo\` to unset it."
|
||||||
|
EXIT_CODE="$(nvm_die_on_prefix 0 foo >/dev/null 2>&1; echo $?)"
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_die_on_prefix 0 foo' did not error with '$EXPECTED_OUTPUT' with bad prefix set; got '$OUTPUT'"
|
||||||
|
[ "_$EXIT_CODE" = "_10" ] || die "'nvm_die_on_prefix 0 foo' did not exit with 10 with bad prefix set; got '$EXIT_CODE'"
|
||||||
|
|
||||||
|
cleanup
|
||||||
@@ -20,4 +20,11 @@ EXIT_CODE=$?
|
|||||||
[ "_$OUTPUT" = "_" ] || die "expected 'nvm_ensure_version_installed 0.1' to have no output, got $OUTPUT"
|
[ "_$OUTPUT" = "_" ] || die "expected 'nvm_ensure_version_installed 0.1' to have no output, got $OUTPUT"
|
||||||
[ "_$EXIT_CODE" = "_0" ] || die "expected 'nvm_ensure_version_installed 0.1' to exit with 0, got $EXIT_CODE"
|
[ "_$EXIT_CODE" = "_0" ] || die "expected 'nvm_ensure_version_installed 0.1' to exit with 0, got $EXIT_CODE"
|
||||||
|
|
||||||
|
# Special case for "iojs"
|
||||||
|
OUTPUT="$(nvm_ensure_version_installed iojs 2>&1)"
|
||||||
|
EXIT_CODE=$?
|
||||||
|
EXPECTED_OUTPUT='N/A: version "iojs" is not yet installed'
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "expected 'nvm_ensure_version_installed iojs' to give $EXPECTED_OUTPUT, got $OUTPUT"
|
||||||
|
[ "_$EXIT_CODE" = "_1" ] || die "expected 'nvm_ensure_version_installed iojs' to exit with 1, got $EXIT_CODE"
|
||||||
|
|
||||||
cleanup
|
cleanup
|
||||||
|
|||||||
10
test/fast/Unit tests/nvm_is_merged_node_version
Executable file
10
test/fast/Unit tests/nvm_is_merged_node_version
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
nvm_is_merged_node_version '4.0' || die '"nvm_is_merged_node_version 4.0 was not true'
|
||||||
|
nvm_is_merged_node_version '5.1' || die '"nvm_is_merged_node_version 5.1 was not true'
|
||||||
|
! nvm_is_merged_node_version '3.99' || die '"nvm_is_merged_node_version 3.99 was not false'
|
||||||
|
! nvm_is_merged_node_version 'v1.0.0' || die '"nvm_is_merged_node_version v1.0.0" was not false'
|
||||||
@@ -8,6 +8,8 @@ cleanup() {
|
|||||||
rm -rf ../../../v0.5.7
|
rm -rf ../../../v0.5.7
|
||||||
rm -rf ../../../v0.7.7
|
rm -rf ../../../v0.7.7
|
||||||
rm -rf ../../../versions/io.js/v0.98.0
|
rm -rf ../../../versions/io.js/v0.98.0
|
||||||
|
rm -rf ../../../versions/node/v1.0.0
|
||||||
|
rm -rf ../../../versions/node/v1.1.0
|
||||||
unset -f nvm_ls_remote nvm_ls_remote_iojs
|
unset -f nvm_ls_remote nvm_ls_remote_iojs
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,6 +34,17 @@ LATEST_UNSTABLE="$(nvm_print_implicit_alias local unstable)"
|
|||||||
LATEST_IOJS="$(nvm_print_implicit_alias local iojs)"
|
LATEST_IOJS="$(nvm_print_implicit_alias local iojs)"
|
||||||
[ "_$LATEST_IOJS" = "_iojs-v0.98" ] || die "local iojs is not latest iojs: expected iojs-v0.98, got $LATEST_IOJS"
|
[ "_$LATEST_IOJS" = "_iojs-v0.98" ] || die "local iojs is not latest iojs: expected iojs-v0.98, got $LATEST_IOJS"
|
||||||
|
|
||||||
|
## node post v1.0/io.js merger ##
|
||||||
|
mkdir -p ../../../versions/node/v1.0.0
|
||||||
|
mkdir -p ../../../versions/node/v1.1.0
|
||||||
|
|
||||||
|
LATEST_STABLE="$(nvm_print_implicit_alias local stable)"
|
||||||
|
[ "_$LATEST_STABLE" = "_1.1" ] || die "local stable when post-v1.0 exists is not latest: expected 1.1, got $LATEST_STABLE"
|
||||||
|
|
||||||
|
LATEST_UNSTABLE="$(nvm_print_implicit_alias local unstable)"
|
||||||
|
[ "_$LATEST_UNSTABLE" = "_0.7" ] || die "local unstable is not latest pre-v1.0 odd minor: expected 0.7, got $LATEST_UNSTABLE"
|
||||||
|
## ** ##
|
||||||
|
|
||||||
nvm_ls_remote() {
|
nvm_ls_remote() {
|
||||||
echo "v0.4.3"
|
echo "v0.4.3"
|
||||||
echo "v0.5.4"
|
echo "v0.5.4"
|
||||||
@@ -65,5 +78,28 @@ LATEST_UNSTABLE="$(nvm_print_implicit_alias remote unstable)"
|
|||||||
LATEST_IOJS="$(nvm_print_implicit_alias remote iojs)"
|
LATEST_IOJS="$(nvm_print_implicit_alias remote iojs)"
|
||||||
[ "_$LATEST_IOJS" = "_iojs-v0.99" ] || die "remote iojs is not latest: expected iojs-v0.99, got $LATEST_IOJS"
|
[ "_$LATEST_IOJS" = "_iojs-v0.99" ] || die "remote iojs is not latest: expected iojs-v0.99, got $LATEST_IOJS"
|
||||||
|
|
||||||
|
## node post v1.0/io.js merger ##
|
||||||
|
nvm_ls_remote() {
|
||||||
|
echo "v0.4.3"
|
||||||
|
echo "v0.5.4"
|
||||||
|
echo "v0.6.6"
|
||||||
|
echo "v0.7.7"
|
||||||
|
echo "v0.9.7"
|
||||||
|
echo "v0.4.3"
|
||||||
|
echo "v0.5.4"
|
||||||
|
echo "v0.6.6"
|
||||||
|
echo "v0.7.7"
|
||||||
|
echo "v0.9.7"
|
||||||
|
echo "v1.0.0"
|
||||||
|
echo "v1.1.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
LATEST_STABLE="$(nvm_print_implicit_alias remote stable)"
|
||||||
|
[ "_$LATEST_STABLE" = "_1.1" ] || die "remote stable when post-v1.0 exists is not latest: expected 1.1, got $LATEST_STABLE"
|
||||||
|
|
||||||
|
LATEST_UNSTABLE="$(nvm_print_implicit_alias remote unstable)"
|
||||||
|
[ "_$LATEST_UNSTABLE" = "_0.9" ] || die "remote unstable is not latest odd pre-v1.0 minor: expected 0.9, got $LATEST_UNSTABLE"
|
||||||
|
## ** ##
|
||||||
|
|
||||||
cleanup
|
cleanup
|
||||||
|
|
||||||
|
|||||||
@@ -22,46 +22,80 @@ HOME="."
|
|||||||
|
|
||||||
setup
|
setup
|
||||||
|
|
||||||
|
#Let's force $SHELL to be bash
|
||||||
|
SHELL="/bin/bash"
|
||||||
|
|
||||||
|
# $SHELL is set to bash and .bashrc is there, it must be detected
|
||||||
|
_PROFILE=$(nvm_detect_profile)
|
||||||
|
[ "_$_PROFILE" = "_$HOME/.bashrc" ] || echo "_\$HOME/.bashrc: _$HOME/.bashrc\n" \
|
||||||
|
echo "_\$_PROFILE: _$_PROFILE\n" \
|
||||||
|
die "nvm_detect_profile didn't pick $SHELL and $HOME/.bashrc"
|
||||||
|
|
||||||
|
#Let's force $SHELL to be zsh
|
||||||
|
SHELL="/usr/bin/zsh"
|
||||||
|
|
||||||
|
# $SHELL is set to zsh and .zshrc is there, it must be detected
|
||||||
|
_PROFILE=$(nvm_detect_profile)
|
||||||
|
[ "_$_PROFILE" = "_$HOME/.zshrc" ] || echo "_\$HOME/.zshrc: _$HOME/.zshrc\n" \
|
||||||
|
echo "_\$_PROFILE: _$_PROFILE\n" \
|
||||||
|
die "nvm_detect_profile didn't pick $SHELL and $HOME/.zshrc"
|
||||||
|
|
||||||
|
|
||||||
|
# if we unset shell it looks for the files
|
||||||
|
unset SHELL
|
||||||
|
|
||||||
# $PROFILE points to a valid file, its path must be returned
|
# $PROFILE points to a valid file, its path must be returned
|
||||||
PROFILE="test_profile"
|
PROFILE="test_profile"
|
||||||
_PROFILE=$(nvm_detect_profile)
|
_PROFILE=$(nvm_detect_profile)
|
||||||
[ "_$_PROFILE" = "_$PROFILE" ] || die "nvm_detect_profile didn't pick \$PROFILE"
|
[ "_$_PROFILE" = "_$PROFILE" ] || echo "_\$_PROFILE: _$_PROFILE\n" \
|
||||||
|
echo "_\$PROFILE: _$PROFILE\n" \
|
||||||
|
die "nvm_detect_profile didn't pick \$PROFILE"
|
||||||
|
|
||||||
# $PROFILE doesn't point to a valid file, its path must not be returned
|
# $PROFILE doesn't point to a valid file, its path must not be returned
|
||||||
PROFILE="invalid_profile"
|
PROFILE="invalid_profile"
|
||||||
_PROFILE=$(nvm_detect_profile)
|
_PROFILE=$(nvm_detect_profile)
|
||||||
[ "_$_PROFILE" != "_$PROFILE" ] || die "nvm_detect_profile shouldn't pick \$PROFILE when it's not a valid file"
|
[ "_$_PROFILE" != "_$PROFILE" ] || echo "_\$_PROFILE: _$_PROFILE\n" \
|
||||||
|
echo "_\$PROFILE: _$PROFILE\n" \
|
||||||
|
die "nvm_detect_profile shouldn't pick \$PROFILE when it's not a valid file"
|
||||||
|
|
||||||
|
|
||||||
# Below are tests for when $PROFILE is undefined
|
# Below are tests for when $PROFILE is undefined
|
||||||
rm test_profile
|
rm test_profile
|
||||||
unset PROFILE
|
unset PROFILE
|
||||||
|
|
||||||
# It should favor .bashrc if file exists
|
# It should favor .profile if file exists
|
||||||
_PROFILE=$(nvm_detect_profile)
|
_PROFILE=$(nvm_detect_profile)
|
||||||
[ "_$_PROFILE" = "_$HOME/.bashrc" ] || die "nvm_detect_profile should have selected .bashrc"
|
[ "_$_PROFILE" = "_$HOME/.profile" ] || echo "_\$_PROFILE: _$_PROFILE\n" \
|
||||||
|
echo "_\$PROFILE: _$PROFILE\n" \
|
||||||
|
die "nvm_detect_profile should have selected .profile"
|
||||||
|
|
||||||
|
rm .profile
|
||||||
|
# Otherwise, it should favor .bashrc if file exists
|
||||||
|
_PROFILE=$(nvm_detect_profile)
|
||||||
|
[ "_$_PROFILE" = "_$HOME/.bashrc" ] || echo "_\$_PROFILE: _$_PROFILE\n" \
|
||||||
|
echo "_\$PROFILE: _$PROFILE\n" \
|
||||||
|
die "nvm_detect_profile should have selected .bashrc"
|
||||||
|
|
||||||
rm .bashrc
|
rm .bashrc
|
||||||
# Otherwise, it should favor .bash_profile if file exists
|
# Otherwise, it should favor .bash_profile if file exists
|
||||||
_PROFILE=$(nvm_detect_profile)
|
_PROFILE=$(nvm_detect_profile)
|
||||||
[ "_$_PROFILE" = "_$HOME/.bash_profile" ] || die "nvm_detect_profile should have selected .bash_profile"
|
[ "_$_PROFILE" = "_$HOME/.bash_profile" ] || echo "_\$_PROFILE: _$_PROFILE\n" \
|
||||||
|
echo "_\$PROFILE: _$PROFILE\n" \
|
||||||
|
die "nvm_detect_profile should have selected .bash_profile"
|
||||||
|
|
||||||
rm .bash_profile
|
rm .bash_profile
|
||||||
# Otherwise, it should favor .zshrc if file exists
|
# Otherwise, it should favor .zshrc if file exists
|
||||||
_PROFILE=$(nvm_detect_profile)
|
_PROFILE=$(nvm_detect_profile)
|
||||||
[ "_$_PROFILE" = "_$HOME/.zshrc" ] || die "nvm_detect_profile should have selected .zshrc"
|
[ "_$_PROFILE" = "_$HOME/.zshrc" ] || echo "_\$_PROFILE: _$_PROFILE\n" \
|
||||||
|
echo "_\$PROFILE: _$PROFILE\n" \
|
||||||
|
die "nvm_detect_profile should have selected .zshrc"
|
||||||
|
|
||||||
rm .zshrc
|
rm .zshrc
|
||||||
# Otherwise, it should favor .profile if file exists
|
|
||||||
_PROFILE=$(nvm_detect_profile)
|
|
||||||
[ "_$_PROFILE" = "_$HOME/.profile" ] || die "nvm_detect_profile should have selected .profile"
|
|
||||||
|
|
||||||
rm .profile
|
|
||||||
# It should be empty if none is found
|
# It should be empty if none is found
|
||||||
_PROFILE=$(nvm_detect_profile)
|
_PROFILE=$(nvm_detect_profile)
|
||||||
[ -z "$_PROFILE" ] || die "nvm_detect_profile should have echo'ed an empty value"
|
[ -z "$_PROFILE" ] || echo "_\$_PROFILE: _$_PROFILE\n" \
|
||||||
|
echo "_\$PROFILE: _$PROFILE\n" \
|
||||||
|
die "nvm_detect_profile should have echo'ed an empty value"
|
||||||
|
|
||||||
|
|
||||||
cleanup
|
cleanup
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ safe_type() {
|
|||||||
safe_type nvm_reset || die 'nvm_reset is not available'
|
safe_type nvm_reset || die 'nvm_reset is not available'
|
||||||
|
|
||||||
# Apply nvm_reset
|
# Apply nvm_reset
|
||||||
nvm_reset
|
nvm_reset || die 'nvm_reset failed'
|
||||||
|
|
||||||
# The names should be unset
|
# The names should be unset
|
||||||
! safe_type nvm_do_install || die 'nvm_do_install is still available'
|
! safe_type nvm_do_install || die 'nvm_do_install is still available'
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ nvm install iojs-v1.0.0
|
|||||||
|
|
||||||
node --version | grep v1.0.0 > /dev/null || die "nvm install didn't use iojs-v1.0.0"
|
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 install -g object-is@0.0.0 || die "npm install -g object-is failed"
|
||||||
npm list --global | grep is-nan > /dev/null || die "is-nan isn't installed"
|
npm list --global | grep object-is > /dev/null || die "object-is 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 ls iojs-1 | grep iojs-v1.0.0 > /dev/null || die "nvm ls iojs-1 didn't show iojs-v1.0.0"
|
||||||
|
|
||||||
@@ -28,5 +28,5 @@ nvm install iojs-v1.0.1 --reinstall-packages-from=iojs-1.0.0 || die "nvm install
|
|||||||
nvm use iojs-1
|
nvm use iojs-1
|
||||||
node --version | grep v1.0.1 > /dev/null || die "nvm use iojs-1 didn't use v1.0.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"
|
npm list --global | grep object-is > /dev/null || die "object-is isn't installed"
|
||||||
|
|
||||||
|
|||||||
25
test/installation/node/install from source without V8 snapshot for ARM
Executable file
25
test/installation/node/install from source without V8 snapshot for ARM
Executable file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
NVM_TEST_VERSION=v0.10.7
|
||||||
|
|
||||||
|
# Remove the stuff we're clobbering.
|
||||||
|
[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION
|
||||||
|
|
||||||
|
# Fake ARM arch
|
||||||
|
nvm_get_arch() {
|
||||||
|
echo "armv7l"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install from source
|
||||||
|
nvm install -s $NVM_TEST_VERSION || die "'nvm install -s $NVM_TEST_VERSION' failed"
|
||||||
|
|
||||||
|
# Check Install
|
||||||
|
[ -d ../../../$NVM_TEST_VERSION ]
|
||||||
|
node --version | grep $NVM_TEST_VERSION || "'node --version | grep $NVM_TEST_VERSION' failed"
|
||||||
|
|
||||||
|
# Check V8 snapshot isn't compiled
|
||||||
|
node -p "if(! process.config.variables.v8_use_snapshot) { console.log('no-snapshot'); }" | grep "no-snapshot" || "'node -p \"if(! process.config.variables.v8_use_snapshot) { console.log('no-snapshot'); }\" | grep \"no-snapshot\"' failed"
|
||||||
@@ -18,8 +18,8 @@ nvm use 0.9.7
|
|||||||
|
|
||||||
node --version | grep v0.9.7 > /dev/null || die "nvm use 0.9.7 failed"
|
node --version | grep v0.9.7 > /dev/null || die "nvm use 0.9.7 failed"
|
||||||
|
|
||||||
npm install -g is-nan@1.0.1 || die "npm install -g is-nan failed"
|
npm install -g object-is@0.0.0 || die "npm install -g object-is failed"
|
||||||
npm list --global | grep is-nan > /dev/null || die "is-nan isn't installed"
|
npm list --global | grep object-is > /dev/null || die "object-is isn't installed"
|
||||||
|
|
||||||
nvm ls 0.9 | grep v0.9.7 > /dev/null || die "nvm ls 0.9 didn't show v0.9.7"
|
nvm ls 0.9 | grep v0.9.7 > /dev/null || die "nvm ls 0.9 didn't show v0.9.7"
|
||||||
|
|
||||||
@@ -30,5 +30,5 @@ nvm install 0.9.12 --reinstall-packages-from=0.9 || die "nvm install 0.9.12 --re
|
|||||||
nvm use 0.9
|
nvm use 0.9
|
||||||
node --version | grep v0.9.12 > /dev/null || die "nvm ls 0.9 didn't use v0.9.12"
|
node --version | grep v0.9.12 > /dev/null || die "nvm ls 0.9 didn't use v0.9.12"
|
||||||
|
|
||||||
npm list --global | grep is-nan > /dev/null || die "is-nan isn't installed"
|
npm list --global | grep object-is > /dev/null || die "object-is isn't installed"
|
||||||
|
|
||||||
|
|||||||
@@ -4,12 +4,15 @@ die () { echo "$@" ; exit 1; }
|
|||||||
|
|
||||||
. ../../../nvm.sh
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
nvm exec 0.10.28 npm install -g npm@~1.4.11 # this is required because before 1.4.10, npm ls doesn't indicated linked packages
|
||||||
|
nvm exec 0.10.29 npm install -g npm@~1.4.11 # this is required because before 1.4.10, npm ls doesn't indicated linked packages
|
||||||
|
|
||||||
nvm use 0.10.28
|
nvm use 0.10.28
|
||||||
(cd test-npmlink && npm link)
|
(cd test-npmlink && npm link)
|
||||||
|
|
||||||
EXPECTED_PACKAGES="autoprefixer bower david eslint grunt-cli grunth-cli http-server jshint marked node-gyp npmlist recursive-blame test-npmlink uglify-js yo"
|
EXPECTED_PACKAGES="autoprefixer bower david eslint grunt-cli grunth-cli http-server jshint marked node-gyp npmlist recursive-blame spawn-sync test-npmlink uglify-js yo"
|
||||||
|
|
||||||
echo "$EXPECTED_PACKAGES" | xargs npm install -g --quiet
|
echo "$EXPECTED_PACKAGES" | sed -e 's/test-npmlink //' | xargs npm install -g --quiet
|
||||||
|
|
||||||
get_packages() {
|
get_packages() {
|
||||||
npm list -g --depth=0 | \sed -e '1 d' -e 's/^.* \(.*\)@.*/\1/' -e '/^npm$/ d' | xargs
|
npm list -g --depth=0 | \sed -e '1 d' -e 's/^.* \(.*\)@.*/\1/' -e '/^npm$/ d' | xargs
|
||||||
|
|||||||
@@ -12,3 +12,9 @@ EXPECTED_OUTPUT="iojs-v1.0.1"
|
|||||||
|
|
||||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|
||||||
|| die "'nvm use iojs' + 'nvm current' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
|| die "'nvm use iojs' + 'nvm current' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||||
|
|
||||||
|
OUTPUT="$(nvm use --silent iojs)"
|
||||||
|
EXPECTED_OUTPUT=""
|
||||||
|
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|
||||||
|
|| die "'nvm use --silent iojs' output was not silenced '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||||
|
|||||||
@@ -12,3 +12,9 @@ EXPECTED_OUTPUT="$(nvm_version stable)"
|
|||||||
|
|
||||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|
||||||
|| die "'nvm use node' + 'nvm current' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
|| die "'nvm use node' + 'nvm current' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||||
|
|
||||||
|
OUTPUT="$(nvm use --silent node)"
|
||||||
|
EXPECTED_OUTPUT=""
|
||||||
|
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|
||||||
|
|| die "'nvm use --silent node' output was not silenced '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||||
|
|||||||
@@ -12,3 +12,9 @@ EXPECTED_OUTPUT="$(nvm_version v1.0.0)"
|
|||||||
|
|
||||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|
||||||
|| die "'nvm use v1.0.0' + 'nvm current' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
|| die "'nvm use v1.0.0' + 'nvm current' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||||
|
|
||||||
|
OUTPUT="$(nvm use --silent 'v1.0.0')"
|
||||||
|
EXPECTED_OUTPUT=""
|
||||||
|
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|
||||||
|
|| die "'nvm use --silent v1.0.0' output was not silenced '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||||
|
|||||||
22
test/slow/nvm use/Running "nvm use" calls "nvm_die_on_prefix"
Executable file
22
test/slow/nvm use/Running "nvm use" calls "nvm_die_on_prefix"
Executable file
@@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
nvm deactivate >/dev/null 2>&1 || die 'deactivate failed'
|
||||||
|
|
||||||
|
nvm_die_on_prefix() {
|
||||||
|
echo >&2 "| $1 | $2 |"
|
||||||
|
return 3
|
||||||
|
}
|
||||||
|
|
||||||
|
OUTPUT="$(nvm use --silent node)"
|
||||||
|
EXPECTED_OUTPUT=""
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|
||||||
|
|| die "'nvm use --silent node' did not call through to 'nvm_die_on_prefix' and give output '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||||
|
|
||||||
|
EXIT_CODE="$(nvm use --silent node >/dev/null 2>&1; echo $?)"
|
||||||
|
EXPECTED_CODE="11"
|
||||||
|
[ "_$EXIT_CODE" = "_$EXPECTED_CODE" ] \
|
||||||
|
|| die "'nvm use --silent node' when 'nvm_die_on_prefix' fails did not return '$EXPECTED_CODE'; got '$EXIT_CODE'"
|
||||||
@@ -10,12 +10,12 @@ cleanup() {
|
|||||||
|
|
||||||
EXPECTED_VERSION="v12.3.456"
|
EXPECTED_VERSION="v12.3.456"
|
||||||
URL="https://github.com/creationix/nvm/releases/tag/$EXPECTED_VERSION"
|
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_CURL_ARGS="-q -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"
|
EXPECTED_WGET_ARGS="http://latest.nvm.sh --server-response -O /dev/null"
|
||||||
|
|
||||||
curl() {
|
curl() {
|
||||||
if [ "_$*" != "_$EXPECTED_CURL_ARGS" ]; then
|
if [ "_$*" != "_$EXPECTED_CURL_ARGS" ]; then
|
||||||
echo 2>& "expected args ($EXPECTED_CURL_ARGS), got ($*)"
|
echo >&2 "expected args ($EXPECTED_CURL_ARGS), got ($*)"
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
echo $URL
|
echo $URL
|
||||||
@@ -23,7 +23,7 @@ curl() {
|
|||||||
}
|
}
|
||||||
wget() {
|
wget() {
|
||||||
if [ "_$*" != "_$EXPECTED_WGET_ARGS" ]; then
|
if [ "_$*" != "_$EXPECTED_WGET_ARGS" ]; then
|
||||||
echo 2>& "expected args ($EXPECTED_WGET_ARGS), got ($*)"
|
echo >&2 "expected args ($EXPECTED_WGET_ARGS), got ($*)"
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
local WGET_CONTENTS
|
local WGET_CONTENTS
|
||||||
@@ -100,7 +100,7 @@ Saving to: ‘/dev/null’
|
|||||||
"
|
"
|
||||||
"$WGET_CONTENTS" | while read line
|
"$WGET_CONTENTS" | while read line
|
||||||
do
|
do
|
||||||
2>& echo "$line"
|
>&2 echo "$line"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
11
test/sourcing/Sourcing nvm.sh with no default should return 0
Executable file
11
test/sourcing/Sourcing nvm.sh with no default should return 0
Executable file
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
touch ../../alias/default
|
||||||
|
rm ../../alias/default || die 'removal of default alias failed'
|
||||||
|
nvm_alias default && die '"nvm_alias default" did not fail'
|
||||||
|
|
||||||
|
set -e # necessary to fail internally with a nonzero code
|
||||||
|
|
||||||
|
. ../../nvm.sh || die 'sourcing returned nonzero exit code'
|
||||||
Reference in New Issue
Block a user