mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-09-03 19:16:33 +00:00
Compare commits
92 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ebdcdc4363 | ||
![]() |
b805de80cb | ||
![]() |
44f416d58f | ||
![]() |
3d1ccfec70 | ||
![]() |
f73ee40dfe | ||
![]() |
2d692d9d78 | ||
![]() |
8aebf86329 | ||
![]() |
39dad845cf | ||
![]() |
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 |
@@ -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.
|
||||
|
||||
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)
|
||||
- [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:
|
||||
- [nvm-fish-wrapper](https://github.com/passcod/nvm-fish-wrapper)
|
||||
- [nvm-fish](https://github.com/Alex7Kom/nvm-fish) (does not support iojs)
|
||||
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:
|
||||
- [bass](https://github.com/edc/bass) allows to use utilities written for Bash in fish shell
|
||||
|
||||
### Install script
|
||||
|
||||
To install you could use the [install script][2] using cURL:
|
||||
|
||||
curl https://raw.githubusercontent.com/creationix/nvm/v0.25.1/install.sh | bash
|
||||
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.28.0/install.sh | bash
|
||||
|
||||
or Wget:
|
||||
|
||||
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.25.1/install.sh | bash
|
||||
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.28.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>
|
||||
|
||||
@@ -76,10 +75,27 @@ In place of a version pointer like "0.10", you can use the special default alias
|
||||
nvm use stable
|
||||
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/):
|
||||
|
||||
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":
|
||||
|
||||
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
|
||||
|
||||
[1]: https://github.com/creationix/nvm.git
|
||||
[2]: https://github.com/creationix/nvm/blob/v0.25.1/install.sh
|
||||
[2]: https://github.com/creationix/nvm/blob/v0.28.0/install.sh
|
||||
[3]: https://travis-ci.org/creationix/nvm
|
||||
[Urchin]: https://github.com/scraperwiki/urchin
|
||||
[Fish]: http://fishshell.com
|
||||
|
@@ -57,7 +57,7 @@ __nvm_aliases ()
|
||||
declare aliases
|
||||
aliases=""
|
||||
if [ -d $NVM_DIR/alias ]; then
|
||||
aliases="`cd $NVM_DIR/alias && ls`"
|
||||
aliases="`cd $NVM_DIR/alias && command ls`"
|
||||
fi
|
||||
echo "${aliases}"
|
||||
}
|
||||
|
50
install.sh
50
install.sh
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
{ # this ensures the entire script is downloaded #
|
||||
|
||||
nvm_has() {
|
||||
type "$1" > /dev/null 2>&1
|
||||
@@ -11,7 +11,7 @@ if [ -z "$NVM_DIR" ]; then
|
||||
fi
|
||||
|
||||
nvm_latest_version() {
|
||||
echo "v0.25.1"
|
||||
echo "v0.28.0"
|
||||
}
|
||||
|
||||
#
|
||||
@@ -115,16 +115,38 @@ install_nvm_as_script() {
|
||||
# Otherwise, an empty string is returned
|
||||
#
|
||||
nvm_detect_profile() {
|
||||
if [ -f "$PROFILE" ]; then
|
||||
echo "$PROFILE"
|
||||
elif [ -f "$HOME/.bashrc" ]; then
|
||||
echo "$HOME/.bashrc"
|
||||
elif [ -f "$HOME/.bash_profile" ]; then
|
||||
echo "$HOME/.bash_profile"
|
||||
elif [ -f "$HOME/.zshrc" ]; then
|
||||
echo "$HOME/.zshrc"
|
||||
elif [ -f "$HOME/.profile" ]; then
|
||||
echo "$HOME/.profile"
|
||||
|
||||
local DETECTED_PROFILE
|
||||
DETECTED_PROFILE=''
|
||||
local SHELLTYPE
|
||||
SHELLTYPE="$(basename /$SHELL)"
|
||||
|
||||
if [ $SHELLTYPE = "bash" ]; then
|
||||
if [ -f "$HOME/.bashrc" ]; then
|
||||
DETECTED_PROFILE="$HOME/.bashrc"
|
||||
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
|
||||
}
|
||||
|
||||
@@ -216,7 +238,7 @@ nvm_do_install() {
|
||||
printf "$SOURCE_STR"
|
||||
echo
|
||||
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"
|
||||
printf "$SOURCE_STR\n" >> "$NVM_PROFILE"
|
||||
else
|
||||
@@ -241,3 +263,5 @@ nvm_reset() {
|
||||
}
|
||||
|
||||
[ "_$NVM_ENV" = "_testing" ] || nvm_do_install
|
||||
|
||||
} # this ensures the entire script is downloaded #
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "nvm",
|
||||
"version": "0.25.1",
|
||||
"version": "0.28.0",
|
||||
"description": "Node Version Manager - Simple bash script to manage multiple active node.js versions",
|
||||
"directories": {
|
||||
"test": "test"
|
||||
@@ -31,7 +31,7 @@
|
||||
"homepage": "https://github.com/creationix/nvm",
|
||||
"devDependencies": {
|
||||
"replace": "^0.3.0",
|
||||
"semver": "^4.3.3",
|
||||
"semver": "^5.0.1",
|
||||
"urchin": "^0.0.5"
|
||||
}
|
||||
}
|
||||
|
13
test/common.sh
Normal file
13
test/common.sh
Normal file
@@ -0,0 +1,13 @@
|
||||
assert_ok() {
|
||||
local FUNCTION=$1
|
||||
shift
|
||||
|
||||
$($FUNCTION $@) || die '"'"$FUNCTION $@"'" should have succeeded, but failed'
|
||||
}
|
||||
|
||||
assert_not_ok() {
|
||||
local FUNCTION=$1
|
||||
shift
|
||||
|
||||
! $($FUNCTION $@) || die '"'"$FUNCTION $@"'" should have failed, but succeeded'
|
||||
}
|
@@ -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
|
||||
|
||||
. ../../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 "$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
|
||||
|
@@ -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" = "_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;
|
||||
|
||||
|
@@ -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" = "_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;
|
||||
|
||||
|
@@ -8,10 +8,15 @@ nvm_has_system_node() { return 0; }
|
||||
nvm_print_npm_version() { return ' (npm v1.2.3)'; }
|
||||
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"
|
||||
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_print_npm_version() { return ''; }
|
||||
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 > /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"
|
||||
|
||||
|
17
test/fast/Unit tests/iojs_version_has_solaris_binary
Executable file
17
test/fast/Unit tests/iojs_version_has_solaris_binary
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
. ../../common.sh
|
||||
|
||||
assert_not_ok iojs_version_has_solaris_binary ""
|
||||
assert_not_ok iojs_version_has_solaris_binary "foo"
|
||||
assert_not_ok iojs_version_has_solaris_binary "v1.1.0"
|
||||
|
||||
assert_ok iojs_version_has_solaris_binary "v3.3.1"
|
||||
assert_ok iojs_version_has_solaris_binary "iojs-v3.3.1"
|
||||
assert_ok iojs_version_has_solaris_binary "v3.3.2"
|
||||
assert_ok iojs_version_has_solaris_binary "iojs-v3.3.2"
|
||||
assert_ok iojs_version_has_solaris_binary "v3.4.1"
|
||||
assert_ok iojs_version_has_solaris_binary "iojs-v3.4.1"
|
33
test/fast/Unit tests/node_version_has_solaris_binary
Executable file
33
test/fast/Unit tests/node_version_has_solaris_binary
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
. ../../common.sh
|
||||
|
||||
# Invalid version numbers fail
|
||||
assert_not_ok node_version_has_solaris_binary ""
|
||||
assert_not_ok node_version_has_solaris_binary "foo"
|
||||
|
||||
# "Invalid" node version numbers fail
|
||||
assert_not_ok node_version_has_solaris_binary "v1.0.0"
|
||||
assert_not_ok node_version_has_solaris_binary "v3.3.1"
|
||||
|
||||
# Valid io.js version numbers that have a Solaris binary fail
|
||||
assert_not_ok node_version_has_solaris_binary "iojs-v3.3.1"
|
||||
|
||||
# Invvalid io.js version numbers fail
|
||||
assert_not_ok node_version_has_solaris_binary "iojs-v0.12.7"
|
||||
|
||||
# Valid node version numbers that don't have a Solaris binary fail
|
||||
assert_not_ok node_version_has_solaris_binary "v0.8.5"
|
||||
|
||||
# Valid node version numbers that have a Solaris binary succeed
|
||||
assert_ok node_version_has_solaris_binary "v0.8.6"
|
||||
assert_ok node_version_has_solaris_binary "v0.10.0"
|
||||
assert_ok node_version_has_solaris_binary "v0.12.7"
|
||||
|
||||
# Valid "merged" version numbers fail, because they're not
|
||||
# considered node version numbers
|
||||
assert_not_ok node_version_has_solaris_binary "v4.0.0"
|
||||
assert_not_ok node_version_has_solaris_binary "v4.1.1"
|
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"
|
||||
[ "_$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
|
||||
|
80
test/fast/Unit tests/nvm_get_arch
Executable file
80
test/fast/Unit tests/nvm_get_arch
Executable file
@@ -0,0 +1,80 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Save the PATH as it was when the test started to restore it when it
|
||||
# finishes
|
||||
ORIG_PATH=$PATH
|
||||
|
||||
cleanup() {
|
||||
# Restore the PATH as it was when the test started
|
||||
export PATH=ORIG_PATH
|
||||
}
|
||||
|
||||
die () { cleanup; echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
# Directory where mocked binaries used by nvm_get_arch for each OS/arch are
|
||||
# located
|
||||
MOCKS_DIR=`pwd`/../../mocks
|
||||
# Sets the PATH for these tests to include the symlinks to the mocked
|
||||
# binaries
|
||||
export PATH=.:${PATH}
|
||||
|
||||
# Setups mock binaries for a given OS and arch that mimic
|
||||
# the output of the real binaries used by nvm_get_arch to guess
|
||||
# the architecture of a given system.
|
||||
setup_mock_arch() {
|
||||
local OS=$1
|
||||
local ARCH=$2
|
||||
local OPT=$3
|
||||
|
||||
if [ "_$OS" = "_solaris" ] || [ "_$OS" = "_smartos" ]; then
|
||||
ln -sf "${MOCKS_DIR}/isainfo_${ARCH}" ./isainfo
|
||||
if [ "_$OPT" != "_no_pkg_info" ]; then
|
||||
ln -sf "${MOCKS_DIR}/pkg_info_${ARCH}" ./pkg_info
|
||||
fi
|
||||
fi
|
||||
|
||||
ln -sf "${MOCKS_DIR}/uname_${OS}_${ARCH}" ./uname
|
||||
}
|
||||
|
||||
# Cleans up the setup done by setup_mock_arch.
|
||||
cleanup_mock_arch() {
|
||||
local OS=$1
|
||||
local ARCH=$2
|
||||
|
||||
if [ "_$OS" = "_solaris" ] || [ "_$OS" = "_smartos" ]; then
|
||||
rm -f ./isainfo
|
||||
rm -f ./pkg_info
|
||||
fi
|
||||
|
||||
rm -f ./uname
|
||||
}
|
||||
|
||||
# Runs nvm_get_arch for architecture $ARCH and OS $OS, and compares the
|
||||
# expected output $EXPECTED_OUTPUT with the actual output. Does nothing
|
||||
# and exits cleanly if they match, dies otherwise.
|
||||
run_test() {
|
||||
local ARCH=$1
|
||||
local OS=$2
|
||||
local EXPECTED_OUTPUT=$3
|
||||
local OPT=$4
|
||||
|
||||
setup_mock_arch $OS $ARCH $OPT
|
||||
local OUTPUT="$(nvm_get_arch)"
|
||||
cleanup_mock_arch $OS $ARCH
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] ||
|
||||
die "nvm_get_arch for OS \"$OS\" and arch \"$ARCH\" with OPT \"$OPT\" did
|
||||
not return \"$EXPECTED_OUTPUT\"; got \"$OUTPUT\""
|
||||
}
|
||||
|
||||
run_test x86 smartos x86
|
||||
run_test x86 smartos x86 no_pkg_info
|
||||
|
||||
run_test amd64 smartos x64
|
||||
run_test amd64 smartos x64 no_pkg_info
|
||||
|
||||
run_test x86 osx x86
|
||||
run_test amd64 osx x64
|
||||
|
||||
cleanup
|
32
test/fast/Unit tests/nvm_has_solaris_binary
Executable file
32
test/fast/Unit tests/nvm_has_solaris_binary
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
. ../../common.sh
|
||||
|
||||
# Invalid version numbers fail
|
||||
assert_not_ok nvm_has_solaris_binary ""
|
||||
assert_not_ok nvm_has_solaris_binary "foo"
|
||||
|
||||
# "Invalid" node version numbers fail
|
||||
assert_not_ok nvm_has_solaris_binary "v1.0.0"
|
||||
assert_not_ok nvm_has_solaris_binary "v3.3.1"
|
||||
|
||||
# Valid io.js version numbers that have a Solaris binary succeed
|
||||
assert_ok nvm_has_solaris_binary "iojs-v3.3.1"
|
||||
|
||||
# Invvalid io.js version numbers fail
|
||||
assert_not_ok nvm_has_solaris_binary "iojs-v0.12.7"
|
||||
|
||||
# Valid node version numbers that don't have a Solaris binary fail
|
||||
assert_not_ok nvm_has_solaris_binary "v0.8.5"
|
||||
|
||||
# Valid node version numbers that have a Solaris binary succeed
|
||||
assert_ok nvm_has_solaris_binary "v0.8.6"
|
||||
assert_ok nvm_has_solaris_binary "v0.10.0"
|
||||
assert_ok nvm_has_solaris_binary "v0.12.7"
|
||||
|
||||
# Valid "merged" version numbers succeed
|
||||
assert_ok nvm_has_solaris_binary "v4.0.0"
|
||||
assert_ok nvm_has_solaris_binary "v4.1.1"
|
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.7.7
|
||||
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
|
||||
}
|
||||
|
||||
@@ -32,6 +34,17 @@ LATEST_UNSTABLE="$(nvm_print_implicit_alias local unstable)"
|
||||
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"
|
||||
|
||||
## 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() {
|
||||
echo "v0.4.3"
|
||||
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" = "_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
|
||||
|
||||
|
@@ -22,46 +22,80 @@ HOME="."
|
||||
|
||||
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="test_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="invalid_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
|
||||
rm test_profile
|
||||
unset PROFILE
|
||||
|
||||
# It should favor .bashrc if file exists
|
||||
# It should favor .profile if file exists
|
||||
_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
|
||||
# Otherwise, it should favor .bash_profile if file exists
|
||||
_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
|
||||
# Otherwise, it should favor .zshrc if file exists
|
||||
_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
|
||||
# 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
|
||||
_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
|
||||
|
||||
|
@@ -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"
|
||||
|
||||
npm install -g is-nan@1.0.1 || die "npm install -g is-nan failed"
|
||||
npm list --global | grep is-nan > /dev/null || die "is-nan isn't installed"
|
||||
npm install -g object-is@0.0.0 || die "npm install -g object-is failed"
|
||||
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"
|
||||
|
||||
@@ -28,5 +28,5 @@ nvm install iojs-v1.0.1 --reinstall-packages-from=iojs-1.0.0 || die "nvm install
|
||||
nvm use iojs-1
|
||||
node --version | grep v1.0.1 > /dev/null || die "nvm use iojs-1 didn't use v1.0.1"
|
||||
|
||||
npm list --global | grep is-nan > /dev/null || die "is-nan isn't installed"
|
||||
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"
|
||||
|
||||
npm install -g is-nan@1.0.1 || die "npm install -g is-nan failed"
|
||||
npm list --global | grep is-nan > /dev/null || die "is-nan isn't installed"
|
||||
npm install -g object-is@0.0.0 || die "npm install -g object-is failed"
|
||||
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"
|
||||
|
||||
@@ -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
|
||||
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"
|
||||
|
||||
|
5
test/mocks/isainfo_amd64
Executable file
5
test/mocks/isainfo_amd64
Executable file
@@ -0,0 +1,5 @@
|
||||
if [ "_$1" = "_-n" ]; then
|
||||
echo "amd64"
|
||||
else
|
||||
echo "amd64 i386"
|
||||
fi
|
5
test/mocks/isainfo_x86
Executable file
5
test/mocks/isainfo_x86
Executable file
@@ -0,0 +1,5 @@
|
||||
if [ "_$1" = "_-n" ]; then
|
||||
echo "i386"
|
||||
else
|
||||
echo "i386"
|
||||
fi
|
1
test/mocks/pkg_info_amd64
Executable file
1
test/mocks/pkg_info_amd64
Executable file
@@ -0,0 +1 @@
|
||||
echo "x86_64"
|
1
test/mocks/pkg_info_x86
Executable file
1
test/mocks/pkg_info_x86
Executable file
@@ -0,0 +1 @@
|
||||
echo "i386"
|
5
test/mocks/uname_osx_amd64
Executable file
5
test/mocks/uname_osx_amd64
Executable file
@@ -0,0 +1,5 @@
|
||||
if [ "_$1" = "_-m" ]; then
|
||||
echo "x86_64"
|
||||
else
|
||||
echo "Darwin foo.local 13.4.0 Darwin Kernel Version 13.4.0: Sun Aug 17 19:50:11 PDT 2014; root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64"
|
||||
fi
|
5
test/mocks/uname_osx_x86
Executable file
5
test/mocks/uname_osx_x86
Executable file
@@ -0,0 +1,5 @@
|
||||
if [ "_$1" = "_-m" ]; then
|
||||
echo "i386"
|
||||
else
|
||||
echo "Darwin foo.local 13.4.0 Darwin Kernel Version 13.4.0: Sun Aug 17 19:50:11 PDT 2014; root:xnu-2422.115.4~1/RELEASE_I386 i386"
|
||||
fi
|
5
test/mocks/uname_smartos_amd64
Executable file
5
test/mocks/uname_smartos_amd64
Executable file
@@ -0,0 +1,5 @@
|
||||
if [ "_$1" = "_-m" ]; then
|
||||
echo "i86pc"
|
||||
else
|
||||
echo "SunOS dev 5.11 joyent_20150219T102159Z i86pc i386 i86pc Solaris"
|
||||
fi
|
5
test/mocks/uname_smartos_x86
Executable file
5
test/mocks/uname_smartos_x86
Executable file
@@ -0,0 +1,5 @@
|
||||
if [ "_$1" = "_-m" ]; then
|
||||
echo "i86pc"
|
||||
else
|
||||
echo "SunOS dev 5.11 joyent_20150219T102159Z i86pc i386 i86pc Solaris"
|
||||
fi
|
@@ -4,12 +4,15 @@ die () { echo "$@" ; exit 1; }
|
||||
|
||||
. ../../../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
|
||||
(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() {
|
||||
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" ] \
|
||||
|| 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" ] \
|
||||
|| 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" ] \
|
||||
|| 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'"
|
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