Compare commits

...

92 Commits

Author SHA1 Message Date
Jordan Harband
ebdcdc4363 v0.28.0 2015-10-02 01:50:44 -07:00
Jordan Harband
b805de80cb Add PREFIX and NPM_CONFIG_PREFIX env vars to nvm debug 2015-10-01 10:05:13 -07:00
Jordan Harband
44f416d58f Create and use nvm_sanitize_path for nvm debug 2015-10-01 09:41:34 -07:00
Jordan Harband
3d1ccfec70 Sort nvm ls results by semver version, so the order goes: "unmerged node", "iojs", "merged node". 2015-09-30 22:05:18 -07:00
Jordan Harband
f73ee40dfe Merge pull request #854 from misterdjules/fix-node-smartos-support
Fix support for installing node on SmartOS
2015-10-01 00:04:13 -07:00
Julien Gilli
2d692d9d78 Fix support for installing node on SmartOS
uname on SmartOS cannot be used to guess if 32 and/or 64 bits binaries
are supported, and its output is different than other uname commands on
other operating systems.

This change uses pkg_info to determine what types of binaries pkgsrc
would install. If pkg_info fails to run or is not present, this change
falls back to using isainfo -n, which determines what the kernel
supports.

It allows users to install node binaries on Solaris derivatives. io.js
can also be installed on Solaris derivatives starting with version
v3.3.1.
2015-09-30 22:10:29 -07:00
Jordan Harband
8aebf86329 v0.27.1 2015-09-27 06:40:29 -07:00
Jordan Harband
39dad845cf Do not exit install.sh on errors (revert part of 0787a559). Fixes #853. 2015-09-27 06:32:00 -07:00
Jordan Harband
838d72688f v0.27.0 2015-09-26 10:13:10 -07:00
Jordan Harband
8ee6f30352 Add support for $NPM_CONFIG_PREFIX to nvm_die_on_prefix.
Fixes #606.
2015-09-23 06:25:55 -07:00
Jordan Harband
1458de7293 Ensure that if npm config get prefix is set to something outside nvm, that nvm use refuses to work.
Fixes #606.
2015-09-21 04:47:37 -07:00
Jordan Harband
a1def71062 Add nvm_die_on_prefix 2015-09-21 04:47:30 -07:00
Jordan Harband
eb81fba8f7 Add support for --silent to nvm run and nvm exec.
Fixes #842.
2015-09-23 05:16:45 -07:00
Jordan Harband
7496a24bd6 Print the npm version when using nvm exec or nvm run. 2015-09-23 05:02:41 -07:00
Jordan Harband
c64a0343af [Docs] Add nvm help documentation for nvm exec 2015-09-23 04:51:55 -07:00
Jordan Harband
643365a948 Allow --silent option to nvm use to be in any position. 2015-09-23 04:51:55 -07:00
Jordan Harband
6e894520ec Use a tighter grep to avoid dnvm.sh conflicts.
Fixes #838.
2015-09-19 22:55:19 +09:00
Jordan Harband
9e389eb9fe Attempt to fix #829. 2015-09-19 13:37:08 +09:00
Jordan Harband
151efc32f5 Merge pull request #827 from lukechilds/master
Revert "Source the nvm.sh file"
2015-09-13 23:57:45 +09:00
Luke Childs
bda1d2ec29 Revert "Source the nvm.sh file"
Fixes #826
This reverts commit b4151e1446.
2015-09-12 23:05:56 +01:00
Jordan Harband
e3528b0d9e Fix nvm_ensure_version_installed iojs to not print an empty string for the version. 2015-09-11 10:42:47 +09:00
Jordan Harband
014a44e154 Minor refactoring to "install from source" logic tree. 2015-09-10 22:37:50 +09:00
Jordan Harband
c9215a127f When no io.js versions are installed, show N/A, not io.js-, as the resolved default alias.
Fixes #822.
2015-09-09 22:37:32 +09:00
Jordan Harband
c92effc6da Don't double-print *default* alias resolutions either. 2015-09-09 22:38:54 +09:00
Jordan Harband
1e2a7a8de4 Sort nvm ls-remote output so the order is: "pre-merged", "iojs", "post-merged". 2015-09-09 22:23:22 +09:00
Jordan Harband
d4caf9fb67 Fix some logic errors in the new "merged node" code path. 2015-09-09 09:46:39 +09:00
Jordan Harband
0ef20199dc Use NVM_VERSION instead of VERSION to be a bit less intrusive.
Fixes #820.
2015-09-07 21:43:21 +09:00
Jordan Harband
0d898b0aa4 When node version is not io.js and is v1.0 or later, on nvm install, run nvm_install_merged_node_binary 2015-08-28 00:51:19 -07:00
Jordan Harband
0181821b51 Add nvm_install_merged_node_binary 2015-08-28 00:51:19 -07:00
Jordan Harband
f34fef96d8 Add nvm_is_merged_node_version 2015-08-28 00:51:18 -07:00
Jordan Harband
26ee4aafc0 v0.26.1 2015-08-22 20:54:31 -07:00
Jordan Harband
8746d63041 Ensure after node v4.0 is released, stable will simply refer to the latest node. 2015-08-22 09:45:49 -07:00
Jordan Harband
b7e2d7d24d Oops, the string passed to awk isn't the same as a shell command.
Fixes #808.
2015-08-16 18:08:50 -07:00
Jordan Harband
58ffa407c2 Prefixing more commands with command to bypass aliases.
Related to #805 and #804.
2015-08-15 23:56:32 -07:00
Jordan Harband
49abc9ce02 v0.26.0 2015-08-13 17:10:08 -07:00
Jordan Harband
15876280f7 Remove trailing whitespace. 2015-08-13 17:09:22 -07:00
Jordan Harband
9f653cc196 Merge pull request #802 from Alex7Kom/master
Replace links to nvm-fish and nvm-fish-wrapper with a link to bass
2015-08-13 00:04:07 -07:00
Alexey Komarov
543b86c060 Replace links to nvm-fish and nvm-fish-wrapper with a link to bass 2015-08-13 09:09:51 +03:00
Jordan Harband
ba01993ea6 Merge pull request #799 from hkdobrev/neither
[Docs] Use "neither" in README
2015-08-10 11:09:46 -07:00
Haralan Dobrev
31e7d5b36a Use neither in README
Correct usage of the [neither-nor](https://en.wiktionary.org/wiki/neither) construction.
2015-08-10 20:34:10 +03:00
Jordan Harband
17c68075e8 Use single quotes instead of double quotes for help output. 2015-08-05 23:53:29 -07:00
Jordan Harband
3fcff872af Add explanatory note for <version>
Per https://github.com/creationix/nvm/pull/797#discussion_r36379740
2015-08-05 23:53:17 -07:00
Jordan Harband
c07838fcc0 Merge pull request #797 from Sequoia/patch-1
Add usage string for --reinstall-packages-from
2015-08-05 21:03:30 -07:00
Sequoia McDowell
fe1ed37520 Add usage string for --reinstall-packages-from 2015-08-05 22:26:17 -04:00
Jordan Harband
ae1c488fe1 Merge pull request #795 from reybango/master
Updated readme file to include --reinstall-packages-from
2015-08-04 14:38:38 -07:00
Rey Bango
d9662f138f Updated based on feedback from @ljharb on syntax description and functionality 2015-08-04 17:35:03 -04:00
Jordan Harband
071323847c Add nvm version-remote; document nvm version 2015-08-04 14:03:57 -07:00
Rey Bango
b7a93be02e Updated to added npm to the text 2015-08-04 15:23:07 -04:00
Rey Bango
3543cd5d2f Updated usage instructions to include --reinstall-packages-from syntax and example 2015-08-04 15:19:38 -04:00
Jordan Harband
d7035c5e61 Redirect stderr output from npm ls -g to /dev/null.
Fixes #756.
2015-08-03 16:41:47 -07:00
Jordan Harband
1f679fc055 Merge pull request #765 from CristianCantoro/master
Detect shell type from $SHELL variable instead of .$SHELLrc files
2015-07-21 16:37:03 -07:00
Cristian Consonni
c37dbbecb4 Detect shell type from $SHELL variable instead of .$SHELLrc files 2015-07-19 02:03:15 +02:00
Jordan Harband
f81b6d6b7b Update semver 2015-07-18 12:20:53 -07:00
Jordan Harband
d57f7ea54a Merge pull request #776 from IonicaBizauKitchen/source-nvm.sh
Source the nvm.sh file upon install
2015-07-18 12:02:08 -07:00
Jordan Harband
759f86f946 Tweaking local variable name to avoid pollution under ksh. 2015-07-18 09:31:07 -07:00
Jordan Harband
60c2f3705e Merge pull request #780 from alanmquach/silent-source
Adding --silent option for nvm use, and using it to disable processing certain output to speed up shell startup

Relates to #781.
2015-07-18 09:29:40 -07:00
Alan Quach
657192dd27 Adding unit tests for --silent 2015-07-10 10:27:35 +10:00
Alan Quach
98e40a8da5 Expanding to full if statements because the shorthand results in non-zero exit codes 2015-07-09 18:40:52 +10:00
Alan Quach
2da44f90d2 Silencing error outputs as well (for consistency and following after things like curl) 2015-07-09 18:00:13 +10:00
Alan Quach
88a50780fc Removing global NVM_SILENT and adding/using '--silent' option to nvm use instead 2015-07-09 17:44:09 +10:00
Alan Quach
9419794b19 Guarding npm version printing with NVM_SILENT flag check; when sourcing nvm.sh, a considerable amount of time is spent running npm --version only for that output to be black-holed to /dev/null 2015-07-09 09:56:26 +10:00
Ionică Bizău
b4151e1446 Source the nvm.sh file
Fixes #775. After everything is installed, instead of restarting the terminal, just load the nvm.sh file.
2015-07-06 11:19:48 +03:00
Jordan Harband
f2d31b0458 Some refactoring to clear up the path to io.js release candidate support.
(unblocks #779)
2015-07-04 17:05:24 -07:00
Jordan Harband
0b41352210 Factor out global installs/links into nvm_npm_global_modules function. 2015-07-02 23:47:29 -07:00
Jordan Harband
be5e8de0c8 Fix nvm reinstall-packages for linked packages, broken in 7bce6c6c68 2015-07-02 23:12:06 -07:00
Jordan Harband
3ef937a64e Make nvm_ensure_version_installed slightly more efficient. 2015-06-28 18:15:15 -07:00
Jordan Harband
a21b2e6962 Refactor this nvm use case statement out into an nvm_match_version function. 2015-06-28 18:08:38 -07:00
Jordan Harband
cc090f4476 Speed up nvm_print_npm_version. 2015-06-28 16:23:12 -07:00
Jordan Harband
c31b072145 Fix nvm debug output in zsh. 2015-06-28 17:19:15 -07:00
Jordan Harband
7bce6c6c68 nvm reinstall-packages should install the same version it had before. 2015-06-29 00:04:59 -07:00
Jordan Harband
fb2f1ac627 Merge pull request #778 from williamboman/chore/rewording
nvm.sh: s/copying/reinstalling/
2015-07-02 12:44:37 -07:00
William Boman
bc3840b6f3 nvm.sh: s/copying/reinstalling/ 2015-07-02 21:21:51 +02:00
Jordan Harband
6b8fd19d76 Merge pull request #766 from lukechilds/master
Add --without-snapshot configure flag to ARM devices by default
2015-06-18 13:42:48 -07:00
lukechilds
c1ef31df53 Remove unnecessary nvm use 2015-06-13 19:38:28 +01:00
lukechilds
3b67b3b9bb Use node instead of nvm run and check v8_use_snapshot in node rather than shell 2015-06-13 18:52:54 +01:00
lukechilds
83466446ce Added newline to end of ARM test 2015-06-13 16:10:49 +01:00
lukechilds
3214caa4ec Adding installation test for disabling V8 snapshot on ARM 2015-06-13 15:58:27 +01:00
lukechilds
67f2ee82ca POSIX compatibility 2015-06-13 10:18:58 +01:00
lukechilds
1f13f15620 Add --without-snapshot configure flag to ARM devices 2015-06-12 23:36:02 +01:00
Jordan Harband
fe044c5e3b spawn-sync now dedupes to the top level with this group of packages. 2015-06-07 01:10:55 -07:00
Jordan Harband
3cfa1ed4e1 Remove $NVM_IOJS_ORG_VERSION_LISTING env var. 2015-06-06 22:39:03 -07:00
Jordan Harband
d78722b284 v0.25.4 2015-05-29 11:11:40 -07:00
Jordan Harband
4c475b2767 Use the original ls instead of aliases.
Fixes #755
2015-05-29 11:11:14 -07:00
Jordan Harband
a539cba11e v0.25.3 2015-05-22 15:18:46 -07:00
Jordan Harband
472ba5fc46 Make sure sourcing nvm.sh on shells that don't support source options doesn't exit nonzero.
Fixes #721
2015-05-22 00:15:43 -07:00
Jordan Harband
96c96ec714 v0.25.2 2015-05-19 14:05:43 -07:00
Jordan Harband
475b8bd6b4 Update semver 2015-05-17 21:12:03 -07:00
Jordan Harband
5e805905ca Add undocumented nvm debug to print out helpful debugging info. 2015-05-14 14:56:26 -07:00
Jordan Harband
2dec01da9c nvm reinstall-packages: On systems where npm ls -g --depth=0 does not include npm for some reason, make sure to filter out (empty). 2015-05-08 14:24:51 -07:00
Jordan Harband
63672641a5 Add wrapping curly braces to ensure that the entire scripts are downloaded.
If the closing curly brace isn't present, the script will error out.
2015-05-11 01:46:18 -07:00
Jordan Harband
94bba31de3 Make sure that nvm reinstall-packages system has the right std output. 2015-05-08 14:15:42 -07:00
Jordan Harband
f70530ef18 Fix installation instructions. 2015-05-07 10:43:47 -07:00
36 changed files with 1114 additions and 178 deletions

View File

@@ -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

View File

@@ -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}"
}

View File

@@ -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 #

686
nvm.sh

File diff suppressed because it is too large Load Diff

View File

@@ -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
View 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'
}

View File

@@ -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

View File

@@ -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;

View File

@@ -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;

View File

@@ -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"

View 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"

View 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"

View 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

View File

@@ -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

View 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

View 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"

View 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'

View File

@@ -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

View File

@@ -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

View File

@@ -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"

View 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"

View File

@@ -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
View File

@@ -0,0 +1,5 @@
if [ "_$1" = "_-n" ]; then
echo "amd64"
else
echo "amd64 i386"
fi

5
test/mocks/isainfo_x86 Executable file
View File

@@ -0,0 +1,5 @@
if [ "_$1" = "_-n" ]; then
echo "i386"
else
echo "i386"
fi

1
test/mocks/pkg_info_amd64 Executable file
View File

@@ -0,0 +1 @@
echo "x86_64"

1
test/mocks/pkg_info_x86 Executable file
View File

@@ -0,0 +1 @@
echo "i386"

5
test/mocks/uname_osx_amd64 Executable file
View 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
View 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
View 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
View File

@@ -0,0 +1,5 @@
if [ "_$1" = "_-m" ]; then
echo "i86pc"
else
echo "SunOS dev 5.11 joyent_20150219T102159Z i86pc i386 i86pc Solaris"
fi

View File

@@ -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

View File

@@ -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'"

View File

@@ -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'"

View File

@@ -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'"

View 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'"

View 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'