Compare commits

...

391 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
Jordan Harband
ec33e8b720 v0.25.1 2015-05-03 15:31:54 -07:00
Jordan Harband
a4f89c6223 Make sure to ignore ~/.curlrc if it exists. 2015-05-01 02:00:49 -07:00
Jordan Harband
517817f1a3 Actually try to install from source when the error message says "binary failed, trying source". 2015-04-27 14:02:45 -07:00
Jordan Harband
a6f5eff0f3 Use uname -m instead of uname -a.
Fixes #744.
2015-04-28 22:56:43 -07:00
Jordan Harband
0aac462b15 Improve the error message when the binary tarball URL 404s.
Fixes #743
2015-04-27 13:48:22 -07:00
Jordan Harband
bb2fe618cb The install script only runs in bash. 2015-04-27 16:55:21 -07:00
Jordan Harband
eb5cecc970 v0.25.0 2015-04-26 12:58:05 -07:00
Jordan Harband
36f933984d Remove trailing whitespace. 2015-04-25 11:21:33 -07:00
Jordan Harband
54d2d70048 Merge pull request #742 from sjasperse/bugfix/rasp-pi-2-arch-detect
adding architecture detection for Raspberry Pi 2
2015-04-26 00:04:00 -07:00
Scott Jasperse
e1009149c9 adding architecture detection for Raspberry Pi 2 2015-04-25 19:10:02 -04:00
Jordan Harband
153ee6887e Merge pull request #741 from phillipsj/master
Adding .gitattributes to force unix line endings.

Fixes #728
2015-04-25 10:58:52 -07:00
Jamie Phillips
295f2b7db4 Adding .gitattributes to force unix line endings.
Hopefully this helps with issue #728
2015-04-25 10:35:22 -04:00
Jordan Harband
356ac7a697 install.sh: Ensure that the --quiet option is available before trying to use it.
Fixes #738, #657.
2015-04-22 00:40:27 -07:00
Jordan Harband
64c88ce62e Merge pull request #735 from madarche/fix-doc
Remove source bashism
2015-04-19 10:32:48 -07:00
Marc-Aurèle DARCHE
4612d8d827 Remove source bashism
Using `.` and not `source`, since it's more portable

cf. #704 and https://wiki.ubuntu.com/DashAsBinSh#source
2015-04-19 16:25:34 +02:00
Jordan Harband
6644f33a77 Update semver, use ^ instead of ~ 2015-04-17 00:24:44 -07:00
Jordan Harband
cbf0f12aac Create nvm_print_npm_version and use that when printing the npm version. 2015-04-12 10:59:17 -07:00
Jordan Harband
de93dc46d0 Merge pull request #726 from SeeThruHead/master
README: Add note about `~/.npmrc` compatibility issues.

Relates to #606.
2015-04-13 13:58:53 -07:00
Shane Keulen
7ea15a7618 Added compatibility issues section
Sections includes warnings for cretain nonstandard path settings and environment variables that conflict with nvm.
2015-04-13 16:54:20 -04:00
Jordan Harband
6a114eddcc Merge pull request #722 from ajcrites/list-npm-version
Include npm version when displaying results of switch.
2015-04-12 10:53:37 -07:00
Andrew Crites
e4149c380b Only print npm version if it exists 2015-04-09 02:31:57 -04:00
Andrew Crites
caa69bc500 npm version: shell compatibility, test update
* Update test string that checks printed node version to pass with additional npm version display
* Remove echo -n for compatibility with shells that do not support it
2015-04-09 02:12:35 -04:00
Andrew Crites
e01bcb740b Include npm version when displaying results of switch.
When running nvm use, successful changing of versions lists the new node version.  The npm version may also be switched, but this is not listed.

This commit updates nvm to display the npm version that was switched to alongside the node version
2015-04-09 01:20:51 -04:00
Jordan Harband
276d55c912 Merge pull request #718 from joliss/performance
Consolidate and avoid sed/cut calls, clean up pattern matches
2015-04-06 21:06:46 -07:00
Jo Liss
0dc177bf9c Consolidate and avoid sed/cut calls, clean up pattern matches
Some patterns contained a no-op `*`; the `*` would match the empty string
because # or % replacement (unlike ## or %%) tries to find the shortest match.
2015-04-06 20:30:38 +00:00
Jordan Harband
c34502ebc2 nvm_num_version_groups should report 0 when given just a v or a . 2015-04-06 11:10:43 -07:00
Jordan Harband
3d764e6833 Add nvm_ensure_default_set 2015-04-05 16:49:29 -07:00
Jordan Harband
a26ef4f1be Consolidate reinstall-packages-from logic to one place nvm install 2015-04-05 16:09:47 -07:00
Jordan Harband
d68f667464 When no arguments are passed to nvm run X, use nvm exec to open a REPL.
Fixes #625. Tests will be in #717.
2015-04-05 15:13:35 -07:00
Jordan Harband
c966204cd6 v0.24.1 2015-04-05 12:55:17 -07:00
Jordan Harband
d72b35b7b8 Remove external calls to sed using parameter filtering.
POSIX-compliant per http://stackoverflow.com/a/25536935/632724

Relates to #709
2015-04-05 02:35:05 -07:00
Jordan Harband
d50a0f46e9 Avoid some external calls by using case statements.
Relates to #709.
2015-04-04 23:59:12 -07:00
Jordan Harband
82393f5b36 Making sure this test passes whether a system node is installed or not. 2015-04-04 23:49:43 -07:00
Jordan Harband
a1a8e5a51b Clean up logic a bit. 2015-04-04 14:53:38 -07:00
Jordan Harband
108f630732 Cache the nvm_node_prefix call. 2015-04-04 14:31:56 -07:00
Jordan Harband
96e73825bd Consolidate faster default alias lookup, and use that explicit version to avoid a second default alias lookup in nvm use default.
Related to #709.
2015-04-04 15:45:40 -07:00
Jordan Harband
9fc20bb14b Merge pull request #710 from joliss/sed
Combine sed and grep commands
2015-04-02 17:00:20 -07:00
Jordan Harband
3401d15a18 Merge pull request #705 from joliss/performance
Improve startup performance. Closes #703
2015-04-02 16:59:38 -07:00
Jo Liss
394e8505d9 Combine sed and grep commands 2015-04-02 16:58:31 +00:00
Jo Liss
fc86834e29 Add comment re nvm_ensure_version_installed performance 2015-04-02 15:30:33 +00:00
Jo Liss
609d9ee4ea Improve startup performance. Closes #703 2015-04-02 15:30:33 +00:00
Jordan Harband
70370a857f No more need for sudo to install ksh and zsh. 2015-03-19 11:05:31 -07:00
Jordan Harband
65a986c633 Merge pull request #693 from hax/reinstall-links
support npm link for reinstall-packages
2015-03-18 22:22:23 -07:00
Jordan Harband
3cc5d6af67 Merge pull request #694 from pfac/pfac-fix-source-nvm-sh-error-message
Fix error message when sourcing nvm.sh
2015-03-18 10:05:22 -07:00
Pedro Costa
999c4111c1 Supresses error message on checking source options 2015-03-18 10:21:11 +00:00
HE Shi-Jun
3d69cf7437 update testcase 2015-03-17 15:54:50 +08:00
HE Shi-Jun
207521d54b support npm link 2015-03-17 14:19:32 +08:00
Jordan Harband
7750253bca Merge pull request #690 from hax/patch-1
Only filter the package `npm`, not any package name that contains 'npm'
2015-03-16 03:10:50 -07:00
HE Shi-Jun
14b23bfa95 fix reinstall-packages test 2015-03-15 06:21:35 +08:00
HE Shi-Jun
bf7bd3e793 Only filter the package npm, not any package name contains 'npm' 2015-03-15 06:21:35 +08:00
Jordan Harband
2b63f37f8d Make nvm_resolve_local_alias not return N/A - that should be done as shallowly as possible. 2015-03-14 10:55:31 -07:00
Jordan Harband
230b479648 Making help error output actually output to stderr consistently. 2015-03-14 10:34:52 -07:00
Jordan Harband
5802ac3ea7 v0.24.0 2015-03-05 21:35:37 -08:00
Jordan Harband
b18126cb15 Merge pull request #686 from jarrettchisholm/master
- fixed return code of 1 when updating from git
2015-03-05 16:53:39 -08:00
Jarrett Chisholm
c16919becd - fixed return code of 1 when updating from git 2015-03-05 18:21:46 -05:00
Jordan Harband
8ae7a37d43 Fix bare nvm use when nvm_ls_current is "none". 2015-03-03 11:29:15 -08:00
Jordan Harband
ceb66d1356 Merge pull request #680 from sayanee/armv6l-armv7l-support
fix: download url for iojs armv6l and armv7l. #678 #227
2015-03-01 22:57:21 -08:00
Sayanee
16a730f4cc amend all variables nvm_arch to capitalise 2015-03-02 12:28:21 +08:00
Sayanee
f8064b259d fix: if case and capitalising variable 2015-03-02 12:19:34 +08:00
Sayanee
f8ee25ab5b fix: local declaration of ksh compatibility 2015-03-02 01:04:29 +08:00
Sayanee
fb48129cd4 add support for node builds for armv6l named as arm-pi 2015-02-28 14:48:38 +08:00
Sayanee
9e154b159e fix: download url for iojs armv6l and armv7l. #678 #227 2015-02-27 09:49:45 +08:00
Jordan Harband
fb853614a7 Use nvm_ensure_version_installed to consistently check if a version is installed.
Fixes #675.
2015-02-22 11:10:19 -08:00
Jordan Harband
0d9329435c Create nvm_ensure_version_installed 2015-02-22 02:26:27 -08:00
Jordan Harband
a0d04d0b6b Preventing an unalias error in tests. 2015-02-22 02:21:00 -08:00
Jordan Harband
6c1a310846 Fix nvm_resolve_alias default from 7d22e0c458 2015-02-22 00:43:14 -08:00
Jordan Harband
758141f41e Remove trailing whitespace 2015-02-22 00:29:25 -08:00
Jordan Harband
7d22e0c458 Separate nvm_resolve_alias's nvm_version behavior into nvm_resolve_local_alias. 2015-02-21 16:10:42 -08:00
Jordan Harband
cd481ff548 When none of the directories exist, don't find within them. 2015-02-20 23:12:44 -08:00
Jordan Harband
12ca8f2607 Add nvm_is_alias unit tests.
Fixes 670.
2015-02-20 13:59:08 -08:00
Jordan Harband
e58d4abf11 Add bash_completion for nvm exec 2015-02-16 00:39:05 -08:00
Jordan Harband
820074e1d7 Make sure checksum commands are not aliases.
Fixes #659, #420, #640.
2015-02-16 00:16:54 -08:00
Jordan Harband
3d6b7976e7 Attempt to fix script install - no shadowing $NVM_SOURCE; nvm-exec and nvm.sh should not both use $NVM_SOURCE since they're different URLs.
Fixes #654.
2015-02-11 14:32:25 -08:00
Jordan Harband
3190effedd Add support for node and iojs implicit aliases. 2015-02-10 23:43:47 -08:00
Jordan Harband
d0617b5b79 Suppressing extraneous output from #622. 2015-02-10 11:07:13 -08:00
Jordan Harband
286c808739 Cache values in local variables to avoid repeated lookups. 2015-02-10 10:36:12 -08:00
Jordan Harband
f0d81e2d33 Revert "install: adding some debugging output"
This reverts commit c8efe3d28a.

Conflicts:
	install.sh
2015-02-09 17:16:56 -08:00
Jordan Harband
4768973a85 Merge pull request #631 from ELLIOTTCABLE/notify-about-global-modules
Notify the user that they're losing access to global modules
2015-02-09 16:54:20 -08:00
elliottcable
4508f7c33e install: further support for older npm versions 2015-02-08 02:43:05 -06:00
elliottcable
ea4264645b install: support npms lower than v2 2015-02-07 21:12:46 -06:00
elliottcable
a216f56443 tests: fail install_script test if npm can't install package 2015-02-07 20:53:53 -06:00
elliottcable
c8efe3d28a install: adding some debugging output 2015-02-07 20:50:10 -06:00
elliottcable
0717d5f995 install: some tweaks and clean-up 2015-02-07 17:17:43 -06:00
elliottcable
6cfc309336 install: Pass global-module check in the absence of npm 2015-02-07 17:17:43 -06:00
elliottcable
dd1a9ca6a0 install: Adding global-module check to function resets 2015-02-07 17:17:43 -06:00
elliottcable
4ba7ee5797 install: Show a warning when global packages exist 2015-02-07 17:17:43 -06:00
Jordan Harband
40c9d6fd11 Merge pull request #648 from passcod/patch-1
Update README: Point fish users in the right direction (relates to #303)
2015-02-07 14:33:20 -08:00
Félix Saparelli
2db71a85a5 Move mention of Fish near the Windows alternatives 2015-02-08 11:31:31 +13:00
Félix Saparelli
64b16faf72 Point fish users in the right direction 2015-02-08 11:05:21 +13:00
Jordan Harband
be56ff3b2e Make sure multiple nvm run arguments get passed through to node/iojs properly.
Fixes #641.
2015-02-07 10:09:37 -08:00
Jordan Harband
59e27f8108 Prevent VERSION='' output caused by double local declaration.
Fixes #644.
2015-02-03 17:28:40 -08:00
Jordan Harband
0f1f3ed29c v0.23.3 2015-02-02 20:26:00 -08:00
Jordan Harband
2116d2ff91 Filter out the io.js version dir from nvm_ls output.
Fixes #642.
2015-02-02 17:41:04 -08:00
Jordan Harband
0b4c1e14cf Ensure that nvm run 0.12 --version errors out sensibly when 0.12 isn't installed. 2015-02-01 13:02:46 -08:00
Jordan Harband
e1b7496cf0 Add nvm_is_valid_version 2015-02-01 13:01:40 -08:00
Jordan Harband
8a87133f71 When there's no nvm run output, don't echo an empty line. 2015-02-01 12:45:51 -08:00
Jordan Harband
0792945824 Bypass sha1sum/sha1 aliases. Fixes #640. 2015-01-30 23:46:42 -08:00
Jordan Harband
a6819b3018 Fix nvm ls v1.0.3 so that it locates iojs-v1.0.3.
Also fix `nvm uninstall v1.0.3` so it won't uninstall it if it's the current version.

node versions will still take priority if there's ever a version overlap.
2015-01-25 12:31:19 -08:00
Jordan Harband
3d3d9d3a8d Merge pull request #633 from gsklee/patch-1
Update README.markdown
2015-01-25 10:13:53 -08:00
G. Kay Lee
3e74bac964 Update README.markdown
Add link to io.js repo as suggested in #618
2015-01-25 15:29:36 +08:00
Jordan Harband
1eaf6b53e4 v0.23.2 2015-01-23 13:53:03 -08:00
Jordan Harband
24c60e4e51 Fix a bug in nvm_remote_version that was breaking nvm install stable/nvm install unstable.
Fixes #630.
2015-01-23 12:09:13 -08:00
Jordan Harband
8822bd719a v0.23.1 2015-01-23 02:08:36 -08:00
Jordan Harband
d90c1eca39 Remove trailing whitespace 2015-01-23 02:08:13 -08:00
Jordan Harband
223f388693 Merge pull request #622 from ohcibi/master
Prefer tee over > to maximize compatibility
2015-01-23 01:52:52 -08:00
Tobias Witt
cba5094652 Provide test case for testing the noclobber option from zsh
This tests the absence of the bug from #615
2015-01-23 09:29:13 +01:00
Tobias Witt
b5d9e547f2 Use tee to replace the alias files content instead of >
As mentioned in #615 it is possible to configure `>` to not override
existing files by default. `tee` is a standard tool that can be used
shell independent.
2015-01-23 09:29:12 +01:00
Jordan Harband
15598899b6 Merge pull request #628 from imyelo/patch-1
add iojs mirror to README
2015-01-22 20:25:13 -08:00
yelo
c8f712a334 add iojs mirror to README 2015-01-23 11:18:51 +08:00
Jordan Harband
2d9494af45 Clarifying install messages, to help with #559 and https://github.com/creationix/nvm/issues/400#issuecomment-71043828 2015-01-22 10:21:04 -08:00
Jordan Harband
2755227d40 Merge pull request #618 from mikeal/patch-1
Adding iojs to README.
2015-01-22 02:27:46 -08:00
Jordan Harband
dd146519a2 Improve nvm use success output for io.js.
Fixes #623
2015-01-21 22:06:38 -08:00
Jordan Harband
7243bd77d3 Refactor and create nvm_remote_versions and nvm_remote_version.
Fixes #620 - an oh-my-zsh issue where `nvm install v1` didn't work.
2015-01-21 20:48:25 -08:00
Jordan Harband
7d113a2b2f Inline this use of nvm_remote_version 2015-01-21 16:27:20 -08:00
Jordan Harband
17df0b9912 Moving the N/A check earlier in nvm install 2015-01-21 16:19:22 -08:00
Jordan Harband
6cac732141 Including this omitted test. 2015-01-20 23:46:29 -08:00
Jordan Harband
9ee864b06f Remove unused variables. 2015-01-20 18:33:51 -08:00
Mikeal Rogers
0471d0ffd6 Adding iojs to README.
Not entirely sure this is the best place for this but it was the best I could find.
2015-01-20 10:21:18 -05:00
Jordan Harband
43a7d78693 v0.23.0 2015-01-19 22:15:06 -08:00
Jordan Harband
879dda6c3d Merge pull request #616 from ljharb/iojs
Add `io.js` support.

This branch adds support for https://github.com/iojs/io.js / https://iojs.org/

The following features should now work:
 - `nvm install iojs` will install the latest `io.js` version. `nvm ls iojs` and `nvm use iojs` will function as you'd expect.
 - `nvm install node` will install the latest stable `node` version. `nvm ls node` and `nvm use node` will function as you'd expect.
 - In general, a specific `io.js` version can be referenced with the "iojs-" prefix. If `node` were to ever release a `v1.0.0`, `v1.0.0` would refer to `node`, and `iojs-v1.0.0` would refer to `io.js`. In the near future, `node-v1.0.0` will also refer to `node` unambiguously. This applies to all `nvm` commands, including working with aliases and `.nvmrc` files.
 - `io.js`, unlike `node`, does not have a SunOS binary. Please open an issue on https://github.com/iojs/io.js if this is actually a problem for anyone, as currently it seems like this won't be for anybody.

**Note**: checksum support upon installation is currently disabled. Relates to https://github.com/iojs/io.js/issues/368.
**Note**: installation of `io.js` directly from source (via the `-s` option) is not yet enabled. This will be added soon.

Relates to https://github.com/iojs/io.js/issues/40 https://github.com/iojs/io.js/issues/420
Fixes #590
2015-01-19 22:14:46 -08:00
Jordan Harband
ea12784629 Clean up nvm ls-remote behavior when one of node/iojs reports N/A.
This change:
 - removes a superfluous N/A
 - fixes the exit code to return 0 unless no version is found
 - enables `nvm install v1` and similar patterns.
2015-01-19 18:35:05 -08:00
Jordan Harband
f1f11e3b7a Ensure nvm_version node and nvm_version node- report the latest stable node version. 2015-01-19 10:05:36 -08:00
Jordan Harband
247bd310ef Clean up nvm uninstall node and nvm uninstall iojs behavior. 2015-01-19 10:04:12 -08:00
Jordan Harband
dbeeb683da Fix nvm_strip_path for >= v0.12.0 node, and all io.js versions. 2015-01-18 23:55:26 -08:00
Jordan Harband
39a75e616d Add support for nvm use node, nvm use iojs, nvm ls node, and nvm ls iojs
Also add `nvm_version node` and `nvm_version iojs` support.
2015-01-18 20:45:02 -06:00
Jordan Harband
3cf68dc18d Add nvm_has_system_iojs 2015-01-18 20:55:48 -06:00
Jordan Harband
654c37bc29 Make sure to add a test for implicit source installation. 2015-01-18 12:11:21 -06:00
Jordan Harband
c6a9f7baae Merge pull request #613 from jsha/https
Move some URLs to HTTPS.
2015-01-18 22:25:12 -08:00
Jacob Hoffman-Andrews
bb2564d6db npmjs.org -> npmjs.com 2015-01-18 22:24:22 -08:00
Jacob Hoffman-Andrews
896a7eddd3 Move some URLs to HTTPS. 2015-01-18 12:05:44 -08:00
Jordan Harband
8ae7b33632 Improving failure messages on this test 2015-01-17 11:52:06 -06:00
Jordan Harband
eb8c3414dd Move nvm_get_latest tests from "installation" to "slow" 2015-01-17 11:52:06 -06:00
Jordan Harband
9615672243 Move node-specific installation tests to their own directory. 2015-01-17 11:52:06 -06:00
Jordan Harband
78c1f2cf9d Split up this nvm current and node 0.6.21-pre test into separate tests. 2015-01-16 15:36:32 -06:00
Jordan Harband
ed22d3de2d Add support for nvm install node and nvm install iojs 2015-01-16 11:10:37 -06:00
Jordan Harband
448bd38a55 v0.22.2 2015-01-14 15:44:40 -08:00
Jordan Harband
0ad5a450fe Put node versions >= 0.12 in versions/node instead of just versions 2015-01-14 12:23:06 -08:00
Jordan Harband
d5e21be164 Add nvm_ensure_version_prefix unit tests. 2015-01-13 23:51:54 -08:00
Jordan Harband
797c5ab70b Move "install node from source" logic into nvm_install_node_source function. 2015-01-13 18:15:42 -08:00
Jordan Harband
952096d034 Add iojs support to "install" 2015-01-13 17:52:18 -08:00
Jordan Harband
dd3a3763ce Add io.js support to nvm uninstall 2015-01-16 10:41:40 -06:00
Jordan Harband
41c379839d Make sure nvm run works with iojs prefixes. 2015-01-15 01:38:47 -08:00
Jordan Harband
d9340b6a53 io.js does not have a SunOS binary. 2015-01-13 17:48:15 -08:00
Jordan Harband
b0d6c05d6e Make nvm ls-remote iojs [foo] only show iojs versions, and nvm ls-remote node [foo] only show node versions. 2015-01-13 14:19:58 -08:00
Jordan Harband
0e209ce890 Move "install node binary" logic into nvm_install_node_binary function. 2015-01-13 14:08:56 -08:00
Jordan Harband
9a57a891b9 Refactor OS and architecture detection into separate functions. 2015-01-13 02:41:55 -08:00
Jordan Harband
58ab2c3128 Add iojs support to nvm_remote_version 2015-01-13 02:22:22 -08:00
Jordan Harband
d70f0357f5 Add nvm_ls_remote_iojs and nvm ls-remote support for iojs. 2015-01-13 02:14:29 -08:00
Jordan Harband
5143de9653 Make nvm_ls_current work with iojs-prefixed versions. 2015-01-13 01:04:45 -08:00
Jordan Harband
5c336a7ccb Make nvm_print_versions support iojs via nvm_version_path. 2015-01-13 00:49:31 -08:00
Jordan Harband
3d5ded1815 Update the way nvm_ls sorts things. 2015-01-13 00:21:33 -08:00
Jordan Harband
f661617f1c Make nvm_ls foo work with iojs-prefixed version strings. 2015-01-12 18:16:11 -08:00
Jordan Harband
d28703f9e0 Update nvm_ensure_version_prefix to support iojs-prefixed version strings. 2015-01-12 18:15:51 -08:00
Jordan Harband
b7983842aa Add nvm_add_iojs_prefix 2015-01-13 00:57:32 -08:00
Jordan Harband
c12104cecd Add nvm_strip_iojs_prefix 2015-01-12 18:15:25 -08:00
Jordan Harband
98e0655198 Add nvm_is_iojs_version 2015-01-12 18:15:15 -08:00
Jordan Harband
c46748a379 Add nvm_node_prefix 2015-01-13 14:16:35 -08:00
Jordan Harband
8be97c8abb Add nvm_iojs_prefix 2015-01-12 18:15:04 -08:00
Jordan Harband
7807a9f09e Consolidate "alias" directory to a method. 2015-01-12 01:27:53 -08:00
Jordan Harband
835c006b5e Better way to search multiple directories in nvm_ls 2015-01-12 01:15:48 -08:00
Jordan Harband
3fa11c35cb Add io.js support to nvm_version_dir 2015-01-12 00:33:13 -08:00
Jordan Harband
34e51f9f02 Proper quoting and $(…) vs . 2015-01-11 12:13:14 -08:00
Jordan Harband
4b5885d69d Store the version path in a local variable for reuse. 2015-01-11 12:04:26 -08:00
Jordan Harband
bf794ff8da Consistently prefix builtins with command 2015-01-11 11:53:24 -08:00
Jordan Harband
0bd7372c64 Rename this local var in nvm_version_dir 2015-01-11 11:38:55 -08:00
Jordan Harband
0a142b7e7a v0.22.1 2015-01-10 19:43:36 -08:00
Jordan Harband
3fc82d6b2f Use command sed for people who alias sed.
Fixes #493.
2015-01-09 01:50:05 -08:00
Jordan Harband
c6489440dc Add nvm_ls_current test for #605 and zsh. 2015-01-01 23:31:55 -08:00
Jordan Harband
67e8939311 Merge pull request #605 from dhcmrlchtdj/fix_which
Fix which command in zsh (#604).
2015-01-01 22:28:30 -08:00
niris
a26007ec0d fix test suit 2015-01-02 12:51:59 +08:00
niris
3f5ce8b93a Fix which command in zsh (#604). 2015-01-02 10:20:57 +08:00
Jordan Harband
8328741792 Removing an unnecessary return $? 2014-12-28 22:29:26 -08:00
Jordan Harband
8e45afb9f1 Move the version to a single location, nvm_latest_version. 2014-12-28 15:59:06 -08:00
Jordan Harband
fd2fb24b03 Refactor nvm_source a bit. 2014-12-28 15:55:44 -08:00
Jordan Harband
4708cc73ef Update semver 2014-12-27 01:39:48 -08:00
Jordan Harband
c91e8d0ba2 v0.22.0 2014-12-26 16:30:21 -08:00
Jordan Harband
f8b143c594 Merge pull request #602 from ljharb/install_on_source
Support `--install` option on sourcing `nvm.sh`
2014-12-26 14:03:22 -08:00
Jordan Harband
9a4e9060d8 Don't bother testing --install option on source, or supporting it, unless the shell supports passing options upon sourcing. 2014-12-26 13:33:33 -08:00
Jordan Harband
3df0caefa5 Support --install option upon sourcing. 2014-12-26 12:19:35 -08:00
Jordan Harband
274369dc40 Remove trailing whitespace 2014-12-22 23:08:03 -08:00
Jordan Harband
bef3a5ce3a v0.21.0 2014-12-22 12:03:33 -08:00
Jordan Harband
0cb8c9ac2f Merge pull request #599 from ljharb/nvm_get_latest
Add `nvm_get_latest`

This relates to #522, #561, #400.

`nvm_get_latest` uses http://latest.nvm.sh which redirects to https://github.com/creationix/nvm/releases/latest which in turn redirects to the latest release tag.
2014-12-22 11:02:07 -08:00
Jordan Harband
25c61594fe Tests for nvm_get_latest 2014-12-21 18:13:59 -08:00
Jordan Harband
0a739e3fa9 Add nvm_get_latest 2014-12-21 16:33:52 -08:00
Jordan Harband
c0a20f2fa3 Update semver 2014-12-19 17:13:00 -08:00
Jordan Harband
2d78d69d4c Properly outputting the version when nvm_version_path outputs the new "versions" subdirectory. 2014-12-19 17:12:38 -08:00
Jordan Harband
9e17b5059c Return the proper exit code of which directly. 2014-12-19 16:23:27 -08:00
Jordan Harband
0ac2c787be Merge pull request #597 from danielb2/which
Fix `nvm which` to use conventional direct path to program, like system `which`
2014-12-19 13:05:39 -08:00
Daniel Bretoi
99ca0de18f revert echoing path. make tests even better 2014-12-19 11:31:46 -08:00
Daniel Bretoi
f196ace5dd style 2014-12-19 11:10:50 -08:00
Daniel Bretoi
d1a90ca15c work like system which. show system node without changing to use it 2014-12-19 11:10:50 -08:00
Jordan Harband
b3178ca925 Add "--quiet" to git commands post-install.
Mentioned in #595.
2014-12-18 10:37:10 -08:00
Jordan Harband
b9df3fccb4 Remove trailing whitespace. 2014-12-17 01:30:29 -08:00
Jordan Harband
f408d68afc Add nvmrc note to nvm which blurb. 2014-12-17 01:30:23 -08:00
Jordan Harband
fc3a30dd0e Add nvm which to bash_completion 2014-12-17 01:29:38 -08:00
Jordan Harband
74b36b09ff Merge pull request #583 from danielb2/which
Adds `nvm which`
2014-12-17 01:26:50 -08:00
Jordan Harband
080f2149ac Update urchin 2014-12-08 21:51:06 -08:00
Jordan Harband
3bd148056e Fixing deactivate tests.
Fixes #357.
2014-12-03 00:04:43 -08:00
Jordan Harband
5edf013127 Merge pull request #591 from mklement0/fix_make_file
obsolete check for the urchin cross-shell test feature; fix for spurious...
2014-12-02 23:40:24 -08:00
Michael Klement
ae908cbff6 obsolete check for the urchin cross-shell test feature; fix for spurious warnings; improved robustness 2014-12-03 01:47:54 -05:00
Daniel Bretoi
7805492bda merge with master 2014-12-02 13:01:37 -08:00
Daniel Bretoi
a1c0c34088 fix to proper echo of nvm which. Checkin test which had been left out 2014-12-02 12:58:07 -08:00
Daniel Bretoi
234b925c7a style and remove nvm deactivate in nvm which 2014-12-02 12:40:23 -08:00
Jordan Harband
8964cb46d3 v0.20.0 2014-11-29 11:23:16 -08:00
Jordan Harband
383f39ab61 Global modules should not be requireable, and npm root -g should not be in $NODE_PATH.
Fixes #586.
2014-11-29 11:22:10 -08:00
Jordan Harband
052743816f $NODE_PATH is special, so this function shouldn't risk clobbering it. 2014-11-28 11:59:45 -06:00
Jordan Harband
7bbcd3a977 v0.19.0 2014-11-23 14:49:38 -08:00
Jordan Harband
e728577627 Rename nvm copy-packages to nvm reinstall-packages, and --copy-packages-from install option to --reinstall-packages-from
For #341. `nvm copy-packages` and install option `--copy-packages-from` will continue to be supported for for at least a full minor release version.
2014-11-22 13:22:24 -08:00
Jordan Harband
c33074cb54 Tweaking formatting of help output; adding nvm exec example. 2014-11-22 10:48:12 -08:00
Jordan Harband
689c52c90d Install nvm-exec as well when installing via script.
Fixes #553.
2014-11-22 10:34:20 -08:00
Jordan Harband
5904d41b25 Fixing a bug in install_as_script, from 516e553093 2014-11-22 10:29:48 -08:00
Daniel Bretoi
0c33fd2598 change to use default behavior for which 2014-11-22 08:17:15 -08:00
Daniel Bretoi
c9a53fe0c7 include nvm which in documentaiton 2014-11-21 17:55:46 -08:00
Daniel Bretoi
8b25457b74 remove redundant lines from test file 2014-11-21 17:53:08 -08:00
Daniel Bretoi
ee520abf78 adding some tests for nvm which 2014-11-21 17:51:49 -08:00
Daniel Bretoi
b63042bd9f forgot to append bin 2014-11-21 16:59:15 -08:00
Daniel Bretoi
382c3aa85e implements nvm which 2014-11-21 16:54:31 -08:00
Jordan Harband
afba4e08fd Temporarily disable ksh tests, per #574 2014-11-15 11:02:00 -06:00
Jordan Harband
ce82109229 Merge pull request #567 from xcambar/nvm_source
[install script] Refactors NVM_SOURCE
2014-11-15 10:23:40 -06:00
Xavier Cambar
516e553093 Refactors NVM_SOURCE 2014-11-06 22:35:24 +01:00
Jordan Harband
e28a257f23 Merge pull request #573 from mklement0/amend_travis_yml
.travis.yml now obtains latest urchin version from the npm registry
2014-11-05 21:54:53 -08:00
Michael Klement
2d8adac785 .travis.yml now obtains latest urchin version from the npm registry instead of directly from GitHub 2014-11-05 23:22:55 -05:00
Jordan Harband
bf4bf008ac Update urchin 2014-11-05 13:58:30 -08:00
Jordan Harband
5f5eb47f14 v0.18.0 2014-11-05 10:59:59 -08:00
Jordan Harband
d09b84de3c Ensure that a system has manpath before invoking it.
Closes #531, fixes #557.
2014-11-02 13:54:54 -08:00
Jordan Harband
4b6075e29b Merge pull request #568 from mklement0/fix_make_file
Fixed Urchin invocation problem in zsh and dash.  Makefile "future-proofed" to take advantage of true cross-shell testing with Urchin, once available.
2014-11-02 13:43:28 -08:00
Michael Klement
781f72c9c8 Makefile now makes use of the -s <shell> option for Urchin, IF it is available, for true cross-shell testing.
Conversely, a warning is issued if it is missing, because that implies that no actual cross-shell testing will take place.

Also, the shell command that determines the set of available test suites is now POSIX-compliant.
2014-11-01 02:18:10 -04:00
Jordan Harband
6ec62fcc79 Merge pull request #564 from xcambar/nvm_detect_profile
Tests for PROFILE detection
2014-10-30 10:24:53 -07:00
Jordan Harband
fc17aaafb1 Merge pull request #541 from mklement0/fix_make_file
Makefile enhanced to error out with instructions if invoked without a target.
2014-10-30 10:23:37 -07:00
Michael Klement
ac912afc4c Many makefile enhancements (support for direct invocation, instructions if invoked without target, release mechanism improved), package.json scripts now invoke the makefile.
- Using `npm test` and `npm run …` scripts defined in package.json now invokes the makefile and runs the test with the same shell that npm was invoked from.
- The makefile can now be invoked directly - supporting utilities from locally installed npm packages are automatically discovered.
- Invoking the makefile without a target errors out with a hint.
- Shell-specific test targets are now named 'test-<shell>'.
- Both 'test-<shell>' targets and the all-shells 'test' target now run all test suites by default.
- On `make TAG=<new-version> release` there must be no uncommitted changes. '<new-version>' can now also be one of the following increment specifiers: 'patch', 'minor', 'major'.
- It is ensure that <new-version>, if not an increment specifier, is a valid semver version number that is higher than the previous release's.
- The previous release tag is now located with a pattern so as to exclude tags that aren't version numbers.
- Switched from lightweight to annotated tags for releases.
2014-10-30 00:13:22 -04:00
Xavier Cambar
b9f15b0ab0 Tests for PROFILE detection 2014-10-29 18:50:04 +01:00
Jordan Harband
d30c0fe146 Cleaning up install_script tests. 2014-10-28 13:47:21 -07:00
Jordan Harband
21534ec0c9 Merge pull request #556 from xcambar/install_function_for_testing
Add install_script test suite; wrap installation in a function, for testing.
2014-10-28 13:42:59 -07:00
Xavier Cambar
3cdec8e875 Testable install script
* wraps main code into a function
* EnvVar-based install start
* Clean environment after install
2014-10-28 11:44:01 +01:00
Jordan Harband
cec1c38a84 Move sourcing tests to a separate test suite. 2014-10-26 23:40:32 -07:00
Jordan Harband
ad0a5cd8c7 Merge pull request #560 from brock/pwd
use `command -p pwd` to use the system default pwd
2014-10-26 01:23:41 -07:00
Brock Angelo
1c9a5ba2d8 use slash pwd instead of command 2014-10-25 22:19:27 -05:00
Brock Angelo
fd1f2cdf66 use command -p pwd to use the system default pwd 2014-10-25 13:55:20 -05:00
Jordan Harband
2d529cc8b7 Prevent attempts to nvm use a circular reference. 2014-10-22 18:15:21 -07:00
Jordan Harband
9b91734f0b Show "∞" when there's a circular alias reference. 2014-10-22 18:15:21 -07:00
Jordan Harband
0f5997f754 Clean up from some more tests 2014-10-22 18:15:21 -07:00
Jordan Harband
7a339bdd3c Adding nvm_resolve_alias 2014-10-22 01:30:40 -07:00
Jordan Harband
08aa09e664 Prevent test pollution. 2014-10-22 01:26:39 -07:00
Jordan Harband
8284cd0f81 Ensuring that there's a stable and unstable version "available" for this test. 2014-10-21 01:02:59 -07:00
Jordan Harband
e421a0dc5f Ensure nvm follows redirects to nodejs.org 2014-10-20 16:02:46 -07:00
Jordan Harband
601490ac1d Merge tag 'v0.17.3' 2014-10-20 15:50:47 -07:00
Jordan Harband
4748b3a236 v0.17.3 2014-10-20 15:48:49 -07:00
Jordan Harband
2a61569881 http://nodejs.org/dist now redirects to https://nodejs.org/dist 2014-10-20 15:48:35 -07:00
Jordan Harband
a7b1f93592 README cleanup: Use the Oxford comma, properly lowercase commands 2014-10-19 19:26:17 -07:00
Jordan Harband
ca89cceb99 Default $NVM_SYMLINK_CURRENT to off (create a "current" symlink on use).
Fixes #499.
2014-10-14 18:14:12 -07:00
Jordan Harband
7b6e06e556 Add tests for "nvm use default on source" behavior. 2014-10-13 23:55:58 -07:00
Jordan Harband
370dfcab7c Merge pull request #548 from BanzaiMan/ha-bug-npm-update
Fix npm update code
2014-10-12 16:35:13 -07:00
Hiro Asari
44d5776110 Fix npm update code
https://npmjs.org/install.sh redirects to https://www.npmjs.org/install.sh
so this code would fail if it ever npm was absent when we get here.
2014-10-12 12:28:38 -04:00
Jordan Harband
d49443e1fb Properly handle nvm_print_implicit_alias splitting in zsh.
Hopefully fixes #546.
2014-10-11 00:41:16 -04:00
Jordan Harband
e99645f402 Don't list uninstalled implicit aliases 2014-10-10 23:46:25 -04:00
Jordan Harband
8f76b35370 Fix nvm alias tests to have both stable and unstable mocks. 2014-10-10 23:46:25 -04:00
Jordan Harband
a2633e5980 Fixing "nvm alias" output redirection. 2014-10-09 00:19:14 -07:00
Jordan Harband
6c89e96f67 Ensure that we don't try to uninstall the current version of node in test teardowns. 2014-10-09 00:19:14 -07:00
Jordan Harband
1ee708b79b Fix an output redirection error. 2014-10-06 16:18:21 -07:00
Jordan Harband
035334fd34 Merge pull request #544 from coreybutler/patch-1
Fixed links
2014-10-05 12:02:30 -07:00
Corey Butler
2edc86d574 Fixed links
The links were relative to github.com/creationix/nvm/master instead of the intended sites.
2014-10-05 10:15:10 -05:00
Jordan Harband
9d23f609ad Add note about Windows options. Related to #284. 2014-10-04 16:42:29 -07:00
Jordan Harband
9d9cfdc2c8 Two spaces after a period is incorrect. 2014-10-04 16:38:56 -07:00
Jordan Harband
1931f7f3f8 Remove '-e' option from installation tests, in favor of explicit failures. 2014-10-03 03:03:48 -07:00
Jordan Harband
2f2c6f0727 Use nvm_alias in nvm_ls. 2014-10-02 17:19:21 -07:00
Jordan Harband
0eef553a88 Use -f instead of -e in nvm_alias. 2014-10-02 16:06:09 -07:00
Jordan Harband
5135577a3c Ensure nvm run has the same semantics as nvm use 2014-10-01 01:46:46 -07:00
Jordan Harband
5bc6e289ce Silencing nvm_version_path error output in nvm_print_versions 2014-10-01 01:46:35 -07:00
Jordan Harband
d0c6b87b2e Use nvm_alias in nvm alias 2014-09-30 00:24:37 -07:00
Jordan Harband
66b214651f Add nvm_alias and unit tests. 2014-09-30 00:23:37 -07:00
Jordan Harband
acfc459bc5 Adding notes to the README for "stable", "unstable", and "system". 2014-09-29 21:43:58 -07:00
Jordan Harband
fc16d20766 Merge pull request #537 from ljharb/add_stable_unstable_aliases
Add stable & unstable aliases.

Fixes #336.

With these changes, the following `nvm` commands will now support "stable" and "unstable" default/implicit aliases:
 - `ls`/`list`
 - `use`
 - `alias`
 - `run`
 - `exec`
 - `uninstall`
 - `copy-packages`

For these, "stable" will be the latest even minor version that's locally installed; "unstable" will be the latest odd minor version that's locally installed.

In addition, `nvm ls-remote` and `nvm install` will accept the same implicit aliases, however, these will actually call nodejs.org and output the latest even and odd minor versions available for installation.

`nvm alias stable foo` and `nvm alias unstable foo` will *override* the default/implicit aliases. `nvm alias` output will reflect this by showing "(default)" when the alias is not user-defined.
2014-09-29 21:35:44 -07:00
Jordan Harband
f0471acbf5 v0.17.2 2014-09-29 14:32:44 -07:00
Jordan Harband
fda05fb64b Remove trailing whitespace. 2014-09-29 14:26:19 -07:00
Jordan Harband
2737a95645 Create nvm_ensure_version_prefix, and make nvm_format_version actually format the version. 2014-09-29 01:36:02 -07:00
Jordan Harband
5706aef3d0 nvm_format_version: add unit tests. 2014-09-29 01:34:50 -07:00
Jordan Harband
4cdf356cdc Support nvm ls-remote stable and nvm ls-remote unstable 2014-09-29 00:10:06 -07:00
Jordan Harband
c918e570b6 Add support for nvm ls stable and nvm ls unstable 2014-09-29 00:09:48 -07:00
Jordan Harband
5dc7af6285 Make nvm alias list implicit "stable" and "unstable" aliases when they're not already aliases. 2014-09-29 00:09:17 -07:00
Jordan Harband
f9565ff675 Adding nvm_print_implicit_alias success tests 2014-09-29 00:08:55 -07:00
Jordan Harband
cea0e88489 Adding nvm_print_implicit_alias error tests. 2014-09-28 22:43:46 -07:00
Jordan Harband
5aad535d53 Adding nvm_print_implicit_alias 2014-09-28 22:40:17 -07:00
Jordan Harband
fcdd1ef431 Add nvm_validate_implicit_alias 2014-09-28 22:36:02 -07:00
Jordan Harband
cd4fc8fb2c Adding unit tests for nvm_ls_remote
`nvm_download` is stubbed, to avoid making network calls.
2014-09-28 22:00:20 -07:00
Jordan Harband
050a2ee9d3 nvm_remote_version: add unit tests
`nvm_ls_remote` is stubbed out to avoid making network calls here.
2014-09-28 18:12:25 -07:00
Jordan Harband
ff92ba7f43 Silence more secondary "deactivate" output. 2014-09-28 16:50:50 -07:00
Jordan Harband
804f2759f8 Ensure that nvm use works when .nvmrc contains "system" 2014-09-28 16:50:50 -07:00
Jordan Harband
d5fe657382 Ensure nvm_rc_version always modifies $NVM_RC_VERSION, rather than retaining its value from previous runs. 2014-09-28 16:50:50 -07:00
Jordan Harband
3e4613fd66 Don't output nvm deactivate output when running nvm use system 2014-09-28 16:50:50 -07:00
Jordan Harband
9aec19a692 Update bash completion commands for nvm 2014-09-28 16:50:49 -07:00
Jordan Harband
b707d8b072 nvm_ls: format the version immediately, so that nvm ls 0.0.1 doesn't return nvm ls 0.0.10 2014-09-28 10:14:27 -07:00
Jordan Harband
be605cb12b Adding a failing test: nvm ls 0.0.x includes v0.0.xy 2014-09-28 10:18:00 -07:00
Jordan Harband
3c66c20570 Improving "nvm alias" tests to test for all cases. 2014-09-28 10:07:50 -07:00
Jordan Harband
59bfdb9863 Making sure fast alias tests do their own teardown. 2014-09-28 09:54:35 -07:00
Jordan Harband
25bd2bb018 Make nvm ls-remote return nvm_ls_remote's exit code. 2014-09-28 09:41:02 -07:00
Jordan Harband
4a8a5a1180 Shell-quoting some more things. 2014-09-27 17:30:09 -07:00
Jordan Harband
145da7eef8 v0.17.1 2014-09-26 23:22:56 -07:00
Jordan Harband
4cf56ae186 Remove unnecessary local var declaration. Fixes #535 2014-09-26 23:22:38 -07:00
Jordan Harband
5ad00f13fa Suppress error messages in case there's no master branch.
Fixes #533.
2014-09-25 22:10:48 -07:00
147 changed files with 5150 additions and 747 deletions

1
.gitattributes vendored Normal file
View File

@@ -0,0 +1 @@
*.sh eol=lf

1
.gitignore vendored
View File

@@ -9,6 +9,7 @@ test/bak
.urchin_stdout
node_modules/
npm-debug.log
.DS_Store
current

View File

@@ -1,24 +1,31 @@
language: c # defaults to ruby
addons:
apt_packages:
- zsh
- ksh
install:
- sudo apt-get install ksh zsh -y
- (mkdir /tmp/urchin && cd /tmp/urchin && curl -s "$(curl -s https://registry.npmjs.com/urchin | grep -Eo '"tarball":\s*"[^"]+"' | tail -n 1 | awk -F\" '{ print $4 }')" -O && tar -x -f urchin*)
- chmod +x /tmp/urchin/package/urchin
- '[ -z "$WITHOUT_CURL" ] || sudo apt-get remove curl -y'
before_script:
- '[ -n "$WITHOUT_CURL" ] || curl -o /tmp/urchin https://raw.githubusercontent.com/scraperwiki/urchin/master/urchin'
- '[ -z "$WITHOUT_CURL" ] || wget -O /tmp/urchin https://raw.githubusercontent.com/scraperwiki/urchin/master/urchin'
- chmod +x /tmp/urchin
script:
- NVM_DIR=$TRAVIS_BUILD_DIR make TEST_SUITE=$TEST_SUITE URCHIN=/tmp/urchin $SHELL
- NVM_DIR=$TRAVIS_BUILD_DIR make TEST_SUITE=$TEST_SUITE URCHIN=/tmp/urchin/package/urchin test-$SHELL
env:
- SHELL=bash TEST_SUITE=install_script
- SHELL=sh TEST_SUITE=fast
- SHELL=dash TEST_SUITE=fast
- SHELL=bash TEST_SUITE=fast
- SHELL=zsh TEST_SUITE=fast
- SHELL=ksh TEST_SUITE=fast
# - SHELL=ksh TEST_SUITE=fast
- SHELL=sh TEST_SUITE=slow
- SHELL=dash TEST_SUITE=slow
- SHELL=bash TEST_SUITE=slow
- SHELL=zsh TEST_SUITE=slow
- SHELL=ksh TEST_SUITE=slow
# - SHELL=ksh TEST_SUITE=slow
- SHELL=sh TEST_SUITE=sourcing
- SHELL=dash TEST_SUITE=sourcing
- SHELL=bash TEST_SUITE=sourcing
- SHELL=zsh TEST_SUITE=sourcing
# - SHELL=ksh TEST_SUITE=sourcing
- SHELL=sh TEST_SUITE=installation
- SHELL=sh TEST_SUITE=installation WITHOUT_CURL=1
- SHELL=dash TEST_SUITE=installation
@@ -27,5 +34,5 @@ env:
- SHELL=bash TEST_SUITE=installation WITHOUT_CURL=1
- SHELL=zsh TEST_SUITE=installation
- SHELL=zsh TEST_SUITE=installation WITHOUT_CURL=1
- SHELL=ksh TEST_SUITE=installation
- SHELL=ksh TEST_SUITE=installation WITHOUT_CURL=1
# - SHELL=ksh TEST_SUITE=installation
# - SHELL=ksh TEST_SUITE=installation WITHOUT_CURL=1

View File

@@ -1,26 +1,77 @@
URCHIN=`which urchin`
SHELLS=sh bash dash ksh zsh
TEST_SUITE=fast
# Since we rely on paths relative to the makefile location, abort if make isn't being run from there.
$(if $(findstring /,$(MAKEFILE_LIST)),$(error Please only invoke this makefile from the directory it resides in))
# Note: With Travis CI:
# - the path to urchin is passed via the command line.
# - the other utilities are NOT needed, so we skip the test for their existence.
URCHIN := urchin
ifeq ($(findstring /,$(URCHIN)),) # urchin path was NOT passed in.
# Add the local npm packages' bin folder to the PATH, so that `make` can find them, when invoked directly.
# Note that rather than using `$(npm bin)` the 'node_modules/.bin' path component is hard-coded, so that invocation works even from an environment
# where npm is (temporarily) unavailable due to having deactivated an nvm instance loaded into the calling shell in order to avoid interference with tests.
export PATH := $(shell printf '%s' "$$PWD/node_modules/.bin:$$PATH")
# The list of all supporting utilities, installed with `npm install`.
UTILS := $(URCHIN) replace semver
# Make sure that all required utilities can be located.
UTIL_CHECK := $(or $(shell PATH="$(PATH)" which $(UTILS) >/dev/null && echo 'ok'),$(error Did you forget to run `npm install` after cloning the repo? At least one of the required supporting utilities not found: $(UTILS)))
endif
# The files that need updating when incrementing the version number.
VERSIONED_FILES := nvm.sh install.sh README.markdown package.json
# Define all shells to test with. Can be overridden with `make SHELLS=... <target>`.
SHELLS := sh bash dash zsh # ksh (#574)
# Generate 'test-<shell>' target names from specified shells.
# The embedded shell names are extracted on demand inside the recipes.
SHELL_TARGETS := $(addprefix test-,$(SHELLS))
# Define the default test suite(s). This can be overridden with `make TEST_SUITE=<...> <target>`.
# Test suites are the names of subfolders of './test'.
TEST_SUITE := $(shell find ./test/* -type d -prune -exec basename {} \;)
.PHONY: $(SHELLS) test verify-tag release
$(SHELLS):
@printf '\n\033[0;34m%s\033[0m\n' "Running tests in $@"
@$@ $(URCHIN) -f test/$(TEST_SUITE)
# Default target (by virtue of being the first non '.'-prefixed in the file).
.PHONY: _no-target-specified
_no-target-specified:
$(error Please specify the target to make - `make list` shows targets. Alternatively, use `npm test` to run the default tests; `npm run` shows all tests)
test: $(SHELLS)
@$(URCHIN) -f test/slow
# Lists all targets defined in this makefile.
.PHONY: list
list:
@$(MAKE) -pRrn : -f $(MAKEFILE_LIST) 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | sort
default: test
# Set of test-<shell> targets; each runs the specified test suites for a single shell.
# Note that preexisting NVM_* variables are unset to avoid interfering with tests, except when running the Travis tests (where NVM_DIR must be passed in and the env. is assumed to be pristine).
.PHONY: $(SHELL_TARGETS)
$(SHELL_TARGETS):
@shell='$@'; shell=$${shell##*-}; which "$$shell" >/dev/null || { printf '\033[0;31m%s\033[0m\n' "WARNING: Cannot test with shell '$$shell': not found." >&2; exit 0; } && \
printf '\n\033[0;34m%s\033[0m\n' "Running tests in $$shell"; \
[ -z "$$TRAVIS_BUILD_DIR" ] && for v in $$(set | awk -F'=' '$$1 ~ "^NVM_" { print $$1 }'); do unset $$v; done && unset v; \
for suite in $(TEST_SUITE); do $(URCHIN) -f -s $$shell test/$$suite || exit; done
verify-tag:
# All-tests target: invokes the specified test suites for ALL shells defined in $(SHELLS).
.PHONY: test
test: $(SHELL_TARGETS)
.PHONY: _ensure-tag
_ensure-tag:
ifndef TAG
$(error TAG is undefined)
$(error Please invoke with `make TAG=<new-version> release`, where <new-version> is either an increment specifier (patch, minor, major, prepatch, preminor, premajor, prerelease), or an explicit major.minor.patch version number)
endif
release: verify-tag
@ OLD_TAG=`git describe --abbrev=0 --tags` && \
replace "$${OLD_TAG/v/}" "$(TAG)" -- nvm.sh install.sh README.markdown package.json && \
git commit -m "v$(TAG)" nvm.sh install.sh README.markdown package.json && \
git tag "v$(TAG)"
# Ensures that the git workspace is clean.
.PHONY: _ensure-clean
_ensure-clean:
@[ -z "$$(git status --porcelain --untracked-files=no || echo err)" ] || { echo "Workspace is not clean; please commit changes first." >&2; exit 2; }
# Makes a release; invoke with `make TAG=<versionOrIncrementSpec> release`.
.PHONY: release
release: _ensure-tag _ensure-clean
@old_ver=`git describe --abbrev=0 --tags --match 'v[0-9]*.[0-9]*.[0-9]*'` || { echo "Failed to determine current version." >&2; exit 1; }; old_ver=$${old_ver#v}; \
new_ver=`echo "$(TAG)" | sed 's/^v//'`; new_ver=$${new_ver:-patch}; \
if printf "$$new_ver" | grep -q '^[0-9]'; then \
semver "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be major.minor.patch' >&2; exit 2; }; \
semver -r "> $$old_ver" "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be HIGHER than current one.' >&2; exit 2; } \
else \
new_ver=`semver -i "$$new_ver" "$$old_ver"` || { echo 'Invalid version-increment specifier: $(TAG)' >&2; exit 2; } \
fi; \
printf "=== Bumping version **$$old_ver** to **$$new_ver** before committing and tagging:\n=== TYPE 'proceed' TO PROCEED, anything else to abort: " && read response && [ "$$response" = 'proceed' ] || { echo 'Aborted.' >&2; exit 2; }; \
replace "$$old_ver" "$$new_ver" -- $(VERSIONED_FILES) && \
git commit -m "v$$new_ver" $(VERSIONED_FILES) && \
git tag -a -m "v$$new_ver" "v$$new_ver"

View File

@@ -2,27 +2,35 @@
## Installation
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 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)). 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.17.0/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.17.0/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>
You can customize the install source, directory and profile using the `NVM_SOURCE`, `NVM_DIR` and `PROFILE` variables. Eg: `curl ... | NVM_DIR=/usr/local/nvm bash` for a global install.
You can customize the install source, directory and profile using the `NVM_SOURCE`, `NVM_DIR`, and `PROFILE` variables.
Eg: `curl ... | NVM_DIR=/usr/local/nvm bash` for a global install.
<sub>*NB. The installer can use Git, curl, or wget to download NVM, whatever is available.*</sub>
<sub>*NB. The installer can use `git`, `curl`, or `wget` to download `nvm`, whatever is available.*</sub>
### Manual install
For manual install create a folder somewhere in your filesystem with the `nvm.sh` file inside it. I put mine in a folder called `nvm`.
For manual install create a folder somewhere in your filesystem with the `nvm.sh` file inside it. I put mine in a folder called `nvm`.
Or if you have `git` installed, then just clone it, and check out the latest version:
@@ -30,7 +38,7 @@ Or if you have `git` installed, then just clone it, and check out the latest ver
To activate nvm, you need to source it from your shell:
source ~/.nvm/nvm.sh
. ~/.nvm/nvm.sh
I always add this line to my `~/.bashrc`, `~/.profile`, or `~/.zshrc` file to have it automatically sourced upon login.
Often I also put in a line to use a specific version of node.
@@ -38,7 +46,7 @@ Often I also put in a line to use a specific version of node.
## Usage
You can create an `.nvmrc` file containing version number in the project root directory (or any parent directory).
`nvm use`, `nvm install`, `nvm exec`, and `nvm run` will all respect an `.nvmrc` file.
`nvm use`, `nvm install`, `nvm exec`, `nvm run`, and `nvm which` will all respect an `.nvmrc` file when a version is not supplied.
To download, compile, and install the latest v0.10.x release of node, do this:
@@ -56,6 +64,43 @@ Or, you can run any arbitrary command in a subshell with the desired version of
nvm exec 0.10 node --version
You can also get the path to the executable to where it was installed:
nvm which 0.10
In place of a version pointer like "0.10", you can use the special default aliases "stable" and "unstable":
nvm install stable
nvm install unstable
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
nvm run system --version
If you want to see what versions are installed:
nvm ls
@@ -70,16 +115,23 @@ To restore your PATH, you can deactivate it.
To set a default Node version to be used in any new shell, use the alias 'default':
nvm alias default 0.10
nvm alias default stable
To use a mirror of the node binaries, set `$NVM_NODEJS_ORG_MIRROR`:
export NVM_NODEJS_ORG_MIRROR=http://nodejs.org/dist
export NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist
nvm install 0.10
NVM_NODEJS_ORG_MIRROR=http://nodejs.org/dist nvm install 0.10
NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist nvm install 0.10
`nvm use` will, by defaut, create a "current" symlink. Set `$NVM_SYMLINK_CURRENT` to any value other than "true" to disable this behavior.
To use a mirror of the iojs binaries, set `$NVM_IOJS_ORG_MIRROR`:
export NVM_IOJS_ORG_MIRROR=https://iojs.org/dist
nvm install iojs-v1.0.3
NVM_IOJS_ORG_MIRROR=https://iojs.org/dist nvm install iojs-v1.0.3
`nvm use` will not, by default, create a "current" symlink. Set `$NVM_SYMLINK_CURRENT` to "true" to enable this behavior, which is sometimes useful for IDEs.
## License
@@ -129,8 +181,9 @@ Put the above sourcing line just below the sourcing line for NVM in your profile
nvm
$ nvm [tab][tab]
alias copy-packages help list run uninstall version
clear-cache deactivate install ls unalias use
alias deactivate install ls run unload
clear-cache exec list ls-remote unalias use
current help list-remote reinstall-packages uninstall version
nvm alias
@@ -150,17 +203,31 @@ nvm uninstall
$ nvm uninstall [tab][tab]
my_alias default v0.6.21 v0.8.26 v0.10.28
## Compatibility Issues
`nvm` will encounter some issues if you have some non-default settings set. (see [#606](/../../issues/606))
The following are known to cause issues:
Inside `~/.npmrc`
```
prefix='some/path'
```
Environment Variables:
```
$NPM_CONFIG_PREFIX
$PREFIX
```
## Problems
If you try to install a node version and the installation fails, be sure to delete the node downloads from src (~/.nvm/src/) or you might get an error when trying to reinstall them again or you might get an error like the following:
curl: (33) HTTP server doesn't seem to support byte ranges. Cannot resume.
Where's my 'sudo node'? Checkout this link:
Where's my 'sudo node'? Check out this link:
https://github.com/creationix/nvm/issues/43
on Arch Linux and other systems using python3 by default, before running *install* you need to
On Arch Linux and other systems using python3 by default, before running *install* you need to
export PYTHON=python2
@@ -169,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.17.0/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

@@ -18,9 +18,11 @@ __nvm_commands ()
current_word="${COMP_WORDS[COMP_CWORD]}"
COMMANDS='\
help install uninstall use run\
ls ls-remote list list-remote deactivate\
alias unalias copy-packages clear-cache version'
help install uninstall use run exec \
alias unalias reinstall-packages \
current list ls list-remote ls-remote \
clear-cache deactivate unload \
version which'
if [ ${#COMP_WORDS[@]} == 4 ]; then
@@ -55,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}"
}
@@ -71,7 +73,7 @@ __nvm ()
previous_word="${COMP_WORDS[COMP_CWORD-1]}"
case "$previous_word" in
use|run|ls|list|uninstall) __nvm_installed_nodes ;;
use|run|exec|ls|list|uninstall) __nvm_installed_nodes ;;
alias|unalias) __nvm_alias ;;
*) __nvm_commands ;;
esac
@@ -79,8 +81,8 @@ __nvm ()
return 0
}
# complete is a bash builtin, but recent versions of ZSH come with a function
# called bashcompinit that will create a complete in ZSH. If the user is in
# complete is a bash builtin, but recent versions of ZSH come with a function
# called bashcompinit that will create a complete in ZSH. If the user is in
# ZSH, load and run bashcompinit before calling the complete function.
if [[ -n ${ZSH_VERSION-} ]]; then
autoload -U +X bashcompinit && bashcompinit

View File

@@ -1,22 +1,51 @@
#!/bin/bash
set -e
{ # this ensures the entire script is downloaded #
nvm_has() {
type "$1" > /dev/null 2>&1
return $?
}
if [ -z "$NVM_DIR" ]; then
NVM_DIR="$HOME/.nvm"
fi
nvm_latest_version() {
echo "v0.28.0"
}
#
# Outputs the location to NVM depending on:
# * The availability of $NVM_SOURCE
# * The method used ("script" or "git" in the script, defaults to "git")
# NVM_SOURCE always takes precedence unless the method is "script-nvm-exec"
#
nvm_source() {
local NVM_METHOD
NVM_METHOD="$1"
local NVM_SOURCE_URL
NVM_SOURCE_URL="$NVM_SOURCE"
if [ "_$NVM_METHOD" = "_script-nvm-exec" ]; then
NVM_SOURCE_URL="https://raw.githubusercontent.com/creationix/nvm/$(nvm_latest_version)/nvm-exec"
elif [ -z "$NVM_SOURCE_URL" ]; then
if [ "_$NVM_METHOD" = "_script" ]; then
NVM_SOURCE_URL="https://raw.githubusercontent.com/creationix/nvm/$(nvm_latest_version)/nvm.sh"
elif [ "_$NVM_METHOD" = "_git" ] || [ -z "$NVM_METHOD" ]; then
NVM_SOURCE_URL="https://github.com/creationix/nvm.git"
else
echo >&2 "Unexpected value \"$NVM_METHOD\" for \$NVM_METHOD"
return 1
fi
fi
echo "$NVM_SOURCE_URL"
}
nvm_download() {
if nvm_has "curl"; then
curl $*
curl -q $*
elif nvm_has "wget"; then
# Emulate curl with wget
ARGS=$(echo "$*" | sed -e 's/--progress-bar /--progress=bar /' \
ARGS=$(echo "$*" | command sed -e 's/--progress-bar /--progress=bar /' \
-e 's/-L //' \
-e 's/-I /--server-response /' \
-e 's/-s /-q /' \
@@ -27,14 +56,10 @@ nvm_download() {
}
install_nvm_from_git() {
if [ -z "$NVM_SOURCE" ]; then
NVM_SOURCE="https://github.com/creationix/nvm.git"
fi
if [ -d "$NVM_DIR/.git" ]; then
echo "=> nvm is already installed in $NVM_DIR, trying to update"
echo "=> nvm is already installed in $NVM_DIR, trying to update using git"
printf "\r=> "
cd "$NVM_DIR" && (git fetch 2> /dev/null || {
cd "$NVM_DIR" && (command git fetch 2> /dev/null || {
echo >&2 "Failed to update nvm, run 'git fetch' in $NVM_DIR yourself." && exit 1
})
else
@@ -42,89 +67,201 @@ install_nvm_from_git() {
echo "=> Downloading nvm from git to '$NVM_DIR'"
printf "\r=> "
mkdir -p "$NVM_DIR"
git clone "$NVM_SOURCE" "$NVM_DIR"
command git clone "$(nvm_source git)" "$NVM_DIR"
fi
cd "$NVM_DIR" && git checkout v0.17.0 && git branch -D master || true
cd "$NVM_DIR" && command git checkout --quiet $(nvm_latest_version)
if [ ! -z "$(cd "$NVM_DIR" && git show-ref refs/heads/master)" ]; then
if git branch --quiet 2>/dev/null; then
cd "$NVM_DIR" && command git branch --quiet -D master >/dev/null 2>&1
else
echo >&2 "Your version of git is out of date. Please update it!"
cd "$NVM_DIR" && command git branch -D master >/dev/null 2>&1
fi
fi
return
}
install_nvm_as_script() {
if [ -z "$NVM_SOURCE" ]; then
NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/v0.17.0/nvm.sh"
fi
local NVM_SOURCE_LOCAL
NVM_SOURCE_LOCAL=$(nvm_source script)
local NVM_EXEC_SOURCE
NVM_EXEC_SOURCE=$(nvm_source script-nvm-exec)
# Downloading to $NVM_DIR
mkdir -p "$NVM_DIR"
if [ -d "$NVM_DIR/nvm.sh" ]; then
echo "=> nvm is already installed in $NVM_DIR, trying to update"
echo "=> nvm is already installed in $NVM_DIR, trying to update the script"
else
echo "=> Downloading nvm as script to '$NVM_DIR'"
fi
nvm_download -s "$NVM_SOURCE" -o "$NVM_DIR/nvm.sh" || {
echo >&2 "Failed to download '$NVM_SOURCE'.."
nvm_download -s "$NVM_SOURCE_LOCAL" -o "$NVM_DIR/nvm.sh" || {
echo >&2 "Failed to download '$NVM_SOURCE_LOCAL'"
return 1
}
nvm_download -s "$NVM_EXEC_SOURCE" -o "$NVM_DIR/nvm-exec" || {
echo >&2 "Failed to download '$NVM_EXEC_SOURCE'"
return 2
}
chmod a+x "$NVM_DIR/nvm-exec" || {
echo >&2 "Failed to mark '$NVM_DIR/nvm-exec' as executable"
return 3
}
}
if [ -z "$METHOD" ]; then
# Autodetect install method
if nvm_has "git"; then
#
# Detect profile file if not specified as environment variable
# (eg: PROFILE=~/.myprofile)
# The echo'ed path is guaranteed to be an existing file
# Otherwise, an empty string is returned
#
nvm_detect_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
}
#
# Check whether the user has any globally-installed npm modules in their system
# Node, and warn them if so.
#
nvm_check_global_modules() {
command -v npm >/dev/null 2>&1 || return 0
local NPM_VERSION
NPM_VERSION="$(npm --version)"
NPM_VERSION="${NPM_VERSION:--1}"
[ "${NPM_VERSION%%[!-0-9]*}" -gt 0 ] || return 0
local NPM_GLOBAL_MODULES
NPM_GLOBAL_MODULES="$(
npm list -g --depth=0 |
sed '/ npm@/d' |
sed '/ (empty)$/d'
)"
local MODULE_COUNT
MODULE_COUNT="$(
printf %s\\n "$NPM_GLOBAL_MODULES" |
sed -ne '1!p' | # Remove the first line
wc -l | tr -d ' ' # Count entries
)"
if [ $MODULE_COUNT -ne 0 ]; then
cat <<-'END_MESSAGE'
=> You currently have modules installed globally with `npm`. These will no
=> longer be linked to the active version of Node when you install a new node
=> with `nvm`; and they may (depending on how you construct your `$PATH`)
=> override the binaries of modules installed with `nvm`:
END_MESSAGE
printf %s\\n "$NPM_GLOBAL_MODULES"
cat <<-'END_MESSAGE'
=> If you wish to uninstall them at a later point (or re-install them under your
=> `nvm` Nodes), you can remove them from the system Node as follows:
$ nvm use system
$ npm uninstall -g a_module
END_MESSAGE
fi
}
nvm_do_install() {
if [ -z "$METHOD" ]; then
# Autodetect install method
if nvm_has "git"; then
install_nvm_from_git
elif nvm_has "nvm_download"; then
install_nvm_as_script
else
echo >&2 "You need git, curl, or wget to install nvm"
exit 1
fi
elif [ "~$METHOD" = "~git" ]; then
if ! nvm_has "git"; then
echo >&2 "You need git to install nvm"
exit 1
fi
install_nvm_from_git
elif nvm_has "nvm_download"; then
elif [ "~$METHOD" = "~script" ]; then
if ! nvm_has "nvm_download"; then
echo >&2 "You need curl or wget to install nvm"
exit 1
fi
install_nvm_as_script
else
echo >&2 "You need git, curl, or wget to install nvm"
exit 1
fi
elif [ "~$METHOD" = "~git" ]; then
if ! nvm_has "git"; then
echo >&2 "You need git to install nvm"
exit 1
fi
install_nvm_from_git
elif [ "~$METHOD" = "~script" ]; then
if ! nvm_has "nvm_download"; then
echo >&2 "You need curl or wget to install nvm"
exit 1
fi
install_nvm_as_script
fi
echo
# Detect profile file if not specified as environment variable (eg: PROFILE=~/.myprofile).
if [ -z "$PROFILE" ]; then
if [ -f "$HOME/.bashrc" ]; then
PROFILE="$HOME/.bashrc"
elif [ -f "$HOME/.bash_profile" ]; then
PROFILE="$HOME/.bash_profile"
elif [ -f "$HOME/.zshrc" ]; then
PROFILE="$HOME/.zshrc"
elif [ -f "$HOME/.profile" ]; then
PROFILE="$HOME/.profile"
fi
fi
SOURCE_STR="\nexport NVM_DIR=\"$NVM_DIR\"\n[ -s \"\$NVM_DIR/nvm.sh\" ] && . \"\$NVM_DIR/nvm.sh\" # This loads nvm"
if [ -z "$PROFILE" ] || [ ! -f "$PROFILE" ] ; then
if [ -z "$PROFILE" ]; then
echo "=> Profile not found. Tried ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile."
echo "=> Create one of them and run this script again"
else
echo "=> Profile $PROFILE not found"
echo "=> Create it (touch $PROFILE) and run this script again"
fi
echo " OR"
echo "=> Append the following lines to the correct file yourself:"
printf "$SOURCE_STR"
echo
else
if ! grep -qc 'nvm.sh' "$PROFILE"; then
echo "=> Appending source string to $PROFILE"
printf "$SOURCE_STR\n" >> "$PROFILE"
else
echo "=> Source string already in $PROFILE"
fi
fi
echo "=> Close and reopen your terminal to start using nvm"
local NVM_PROFILE
NVM_PROFILE=$(nvm_detect_profile)
SOURCE_STR="\nexport NVM_DIR=\"$NVM_DIR\"\n[ -s \"\$NVM_DIR/nvm.sh\" ] && . \"\$NVM_DIR/nvm.sh\" # This loads nvm"
if [ -z "$NVM_PROFILE" ] ; then
echo "=> Profile not found. Tried $NVM_PROFILE (as defined in \$PROFILE), ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile."
echo "=> Create one of them and run this script again"
echo "=> Create it (touch $NVM_PROFILE) and run this script again"
echo " OR"
echo "=> Append the following lines to the correct file yourself:"
printf "$SOURCE_STR"
echo
else
if ! command grep -qc '/nvm.sh' "$NVM_PROFILE"; then
echo "=> Appending source string to $NVM_PROFILE"
printf "$SOURCE_STR\n" >> "$NVM_PROFILE"
else
echo "=> Source string already in $NVM_PROFILE"
fi
fi
nvm_check_global_modules
echo "=> Close and reopen your terminal to start using nvm"
nvm_reset
}
#
# Unsets the various functions defined
# during the execution of the install script
#
nvm_reset() {
unset -f nvm_reset nvm_has nvm_latest_version \
nvm_source nvm_download install_nvm_as_script install_nvm_from_git \
nvm_detect_profile nvm_check_global_modules nvm_do_install
}
[ "_$NVM_ENV" = "_testing" ] || nvm_do_install
} # this ensures the entire script is downloaded #

View File

@@ -11,4 +11,3 @@ else
fi
exec $@

2025
nvm.sh Normal file → Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -1,15 +1,17 @@
{
"name": "nvm",
"version": "0.17.0",
"version": "0.28.0",
"description": "Node Version Manager - Simple bash script to manage multiple active node.js versions",
"directories": {
"test": "test"
},
"scripts": {
"test": "urchin test",
"test/fast": "urchin -f test/fast",
"test/slow": "urchin -f test/slow",
"test/installation": "urchin -f test/installation"
"test": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make test-$shell",
"test/fast": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=fast test-$shell",
"test/slow": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=slow test-$shell",
"test/install_script": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=install_script test-$shell",
"test/installation": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=installation test-$shell",
"test/sourcing": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=sourcing test-$shell"
},
"repository": {
"type": "git",
@@ -28,7 +30,8 @@
},
"homepage": "https://github.com/creationix/nvm",
"devDependencies": {
"urchin": "~0.0.2"
"replace": "^0.3.0",
"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

@@ -0,0 +1,21 @@
#!/bin/sh
. ../../../nvm.sh
die () { echo $@ ; exit 1; }
if [ -n "$ZSH_VERSION" ]; then
# set clobber option in order to test that this does not produce any
# incompatibilities
setopt noclobber
fi
nvm alias test-stable-1 0.0.2
nvm alias test-stable-1 | \grep -e "test-stable-1 -> 0.0.2 (-> v0.0.2)" \
|| die "nvm alias test-stable-1 0.0.2 did not set test-stable-1 to 0.0.2"
nvm alias test-stable-1 0.0.1
nvm alias test-stable-1 | \grep -e "test-stable-1 -> 0.0.1 (-> v0.0.1)" \
|| die "nvm alias test-stable-1 0.0.1 did not set test-stable-1 to 0.0.1"

View File

@@ -1,4 +1,4 @@
#!/bin/sh
. ../../../nvm.sh
[ $(nvm alias test1 | wc -l) = '2' ]
[ $(nvm alias test-stable-1 | wc -l) = '2' ]

View File

@@ -0,0 +1,26 @@
#!/bin/sh
. ../../../nvm.sh
die () { echo $@ ; exit 1; }
NVM_ALIAS_OUTPUT=$(nvm alias)
EXPECTED_STABLE="$(nvm_print_implicit_alias local stable)"
STABLE_VERSION="$(nvm_version "$EXPECTED_STABLE")"
echo "$NVM_ALIAS_OUTPUT" | \grep -e "^stable -> $EXPECTED_STABLE (-> $STABLE_VERSION) (default)$" \
|| die "nvm alias did not contain the default local stable node version"
echo "$NVM_ALIAS_OUTPUT" | \grep -e "^node -> stable (-> $STABLE_VERSION) (default)$" \
|| die "nvm alias did not contain the default local stable node version under 'node'"
EXPECTED_UNSTABLE="$(nvm_print_implicit_alias local unstable)"
UNSTABLE_VERSION="$(nvm_version "$EXPECTED_UNSTABLE")"
echo "$NVM_ALIAS_OUTPUT" | \grep -e "^unstable -> $EXPECTED_UNSTABLE (-> $UNSTABLE_VERSION) (default)$" \
|| die "nvm alias did not contain the default local unstable node version"
EXPECTED_IOJS="$(nvm_print_implicit_alias local iojs)"
IOJS_VERSION="$(nvm_version "$EXPECTED_IOJS")"
echo "$NVM_ALIAS_OUTPUT" | \grep -e "^iojs -> $EXPECTED_IOJS (-> $IOJS_VERSION) (default)$" \
|| die "nvm alias did not contain the default local iojs version"

View File

@@ -0,0 +1,49 @@
#!/bin/sh
. ../../../nvm.sh
die () { echo $@ ; cleanup ; exit 1; }
cleanup () {
rm -rf ../../../alias/stable
rm -rf ../../../alias/unstable
rm -rf ../../../alias/node
rm -rf ../../../alias/iojs
rm -rf ../../../v0.8.1
rm -rf ../../../v0.9.1
rm -rf ../../../versions/io.js/v0.2.1
}
mkdir ../../../v0.8.1
mkdir ../../../v0.9.1
mkdir -p ../../../versions/io.js/v0.2.1
EXPECTED_STABLE="$(nvm_print_implicit_alias local stable)"
STABLE_VERSION="$(nvm_version "$EXPECTED_STABLE")"
EXPECTED_UNSTABLE="$(nvm_print_implicit_alias local unstable)"
UNSTABLE_VERSION="$(nvm_version "$EXPECTED_UNSTABLE")"
[ "_$STABLE_VERSION" != "_$UNSTABLE_VERSION" ] \
|| die "stable and unstable versions are the same!"
nvm alias stable "$EXPECTED_UNSTABLE"
nvm alias unstable "$EXPECTED_STABLE"
nvm alias node stable
nvm alias iojs unstable
NVM_ALIAS_OUTPUT=$(nvm alias)
echo "$NVM_ALIAS_OUTPUT" | command grep -e "^stable -> $EXPECTED_UNSTABLE (-> $UNSTABLE_VERSION)$" \
|| die "nvm alias did not contain the overridden 'stable' alias"
echo "$NVM_ALIAS_OUTPUT" | command grep -e "^unstable -> $EXPECTED_STABLE (-> $STABLE_VERSION)$" \
|| die "nvm alias did not contain the overridden 'unstable' alias"
echo "$NVM_ALIAS_OUTPUT" | command grep -e "^node -> stable (-> $UNSTABLE_VERSION)$" \
|| die "nvm alias did not contain the overridden 'node' alias"
echo "$NVM_ALIAS_OUTPUT" | command grep -e "^iojs -> unstable (-> $STABLE_VERSION)$" \
|| die "nvm alias did not contain the overridden 'iojs' alias"
cleanup

View File

@@ -1,4 +1,48 @@
#!/bin/sh
. ../../../nvm.sh
[ $(nvm alias | wc -l) = '10' ]
die () { echo $@ ; exit 1; }
NVM_ALIAS_OUTPUT=$(nvm alias)
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-stable-1 -> 0.0.1 (-> v0.0.1)$' \
|| die "did not find test-stable-1 alias"
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-stable-2 -> 0.0.2 (-> v0.0.2)$' \
|| die "did not find test-stable-2 alias"
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-stable-3 -> 0.0.3 (-> v0.0.3)$' \
|| die "did not find test-stable-3 alias"
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-stable-4 -> 0.0.4 (-> v0.0.4)$' \
|| die "did not find test-stable-4 alias"
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-stable-5 -> 0.0.5 (-> v0.0.5)$' \
|| die "did not find test-stable-5 alias"
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-stable-6 -> 0.0.6 (-> v0.0.6)$' \
|| die "did not find test-stable-6 alias"
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-stable-7 -> 0.0.7 (-> v0.0.7)$' \
|| die "did not find test-stable-7 alias"
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-stable-8 -> 0.0.8 (-> v0.0.8)$' \
|| die "did not find test-stable-8 alias"
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-stable-9 -> 0.0.9 (-> v0.0.9)$' \
|| die "did not find test-stable-9 alias"
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-stable-10 -> 0.0.10 (-> v0.0.10)$' \
|| die "did not find test-stable-10 alias"
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-unstable-1 -> 0.1.1 (-> v0.1.1)$' \
|| die "did not find test-unstable-1 alias"
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-unstable-2 -> 0.1.2 (-> v0.1.2)$' \
|| die "did not find test-unstable-2 alias"
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-unstable-3 -> 0.1.3 (-> v0.1.3)$' \
|| die "did not find test-unstable-3 alias"
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-unstable-4 -> 0.1.4 (-> v0.1.4)$' \
|| die "did not find test-unstable-4 alias"
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-unstable-5 -> 0.1.5 (-> v0.1.5)$' \
|| die "did not find test-unstable-5 alias"
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-unstable-6 -> 0.1.6 (-> v0.1.6)$' \
|| die "did not find test-unstable-6 alias"
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-unstable-7 -> 0.1.7 (-> v0.1.7)$' \
|| die "did not find test-unstable-7 alias"
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-unstable-8 -> 0.1.8 (-> v0.1.8)$' \
|| die "did not find test-unstable-8 alias"
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-unstable-9 -> 0.1.9 (-> v0.1.9)$' \
|| die "did not find test-unstable-9 alias"
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-unstable-10 -> 0.1.10 (-> v0.1.10)$' \
|| die "did not find test-unstable-10 alias"

View File

@@ -0,0 +1,36 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../../nvm.sh
ALIAS="$(nvm_resolve_alias loopback)"
[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_alias loopback was not ∞; got $ALIAS"
OUTPUT="$(nvm alias loopback)"
EXPECTED_OUTPUT="loopback -> loopback (-> ∞)"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm alias loopback was not $EXPECTED_OUTPUT; got $OUTPUT"
ALIAS="$(nvm_resolve_alias one)"
[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_alias one was not ∞; got $ALIAS"
OUTPUT="$(nvm alias one)"
EXPECTED_OUTPUT="one -> two (-> ∞)"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm alias one was not $EXPECTED_OUTPUT; got $OUTPUT"
ALIAS="$(nvm_resolve_alias two)"
[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_alias two was not ∞; got $ALIAS"
OUTPUT="$(nvm alias two)"
EXPECTED_OUTPUT="two -> three (-> ∞)"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm alias two was not $EXPECTED_OUTPUT; got $OUTPUT"
ALIAS="$(nvm_resolve_alias three)"
[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_alias three was not ∞; got $ALIAS"
OUTPUT="$(nvm alias three)"
EXPECTED_OUTPUT="three -> one (-> ∞)"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm alias three was not $EXPECTED_OUTPUT; got $OUTPUT"
ALIAS="$(nvm_resolve_alias four)"
[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_alias four was not ∞; got $ALIAS"
OUTPUT="$(nvm alias four)"
EXPECTED_OUTPUT="four -> two (-> ∞)"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm alias four was not $EXPECTED_OUTPUT; got $OUTPUT"

View File

@@ -0,0 +1,36 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../../nvm.sh
ALIAS="$(nvm_resolve_local_alias loopback)"
[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_local_alias loopback was not ∞; got $ALIAS"
OUTPUT="$(nvm alias loopback)"
EXPECTED_OUTPUT="loopback -> loopback (-> ∞)"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm alias loopback was not $EXPECTED_OUTPUT; got $OUTPUT"
ALIAS="$(nvm_resolve_local_alias one)"
[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_local_alias one was not ∞; got $ALIAS"
OUTPUT="$(nvm alias one)"
EXPECTED_OUTPUT="one -> two (-> ∞)"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm alias one was not $EXPECTED_OUTPUT; got $OUTPUT"
ALIAS="$(nvm_resolve_local_alias two)"
[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_local_alias two was not ∞; got $ALIAS"
OUTPUT="$(nvm alias two)"
EXPECTED_OUTPUT="two -> three (-> ∞)"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm alias two was not $EXPECTED_OUTPUT; got $OUTPUT"
ALIAS="$(nvm_resolve_local_alias three)"
[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_local_alias three was not ∞; got $ALIAS"
OUTPUT="$(nvm alias three)"
EXPECTED_OUTPUT="three -> one (-> ∞)"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm alias three was not $EXPECTED_OUTPUT; got $OUTPUT"
ALIAS="$(nvm_resolve_local_alias four)"
[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_local_alias four was not ∞; got $ALIAS"
OUTPUT="$(nvm alias four)"
EXPECTED_OUTPUT="four -> two (-> ∞)"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm alias four was not $EXPECTED_OUTPUT; got $OUTPUT"

View File

@@ -0,0 +1,10 @@
#!/bin/sh
echo loopback > ../../../../alias/loopback
echo two > ../../../../alias/one
echo three > ../../../../alias/two
echo one > ../../../../alias/three
echo two > ../../../../alias/four

View File

@@ -0,0 +1,10 @@
#!/bin/sh
rm -f ../../../../alias/loopback
rm -f ../../../../alias/one
rm -f ../../../../alias/two
rm -f ../../../../alias/three
rm -f ../../../../alias/four

View File

@@ -0,0 +1,18 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
nvm alias default 0.1 >/dev/null || die "'nvm alias default 0.1' failed"
nvm_ensure_default_set 0.3 || die "'nvm_ensure_default_set' with an existing default alias exits 0"
nvm unalias default || die "'nvm unalias default' failed"
OUTPUT="$(nvm_ensure_default_set 0.2)"
EXPECTED_OUTPUT="Creating default alias: default -> 0.2 (-> iojs-v0.2.10)"
EXIT_CODE="$?"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_ensure_default_set 0.2' did not output '$EXPECTED_OUTPUT', got '$OUTPUT'"
[ "_$EXIT_CODE" = "_0" ] || die "'nvm_ensure_default_set 0.2' did not exit with 0, got $EXIT_CODE"

View File

@@ -0,0 +1,33 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
EXIT_CODE=$(nvm_resolve_alias ; echo $?)
[ $EXIT_CODE = "1" ] || die "nvm_resolve_alias without an argument did not return 1; got $EXIT_CODE"
for i in $(seq 1 10)
do
STABLE_ALIAS="$(nvm_resolve_alias test-stable-$i)"
[ "_$STABLE_ALIAS" = "_v0.0.$i" ] \
|| die "'nvm_resolve_alias test-stable-$i' was not v0.0.$i; got $STABLE_ALIAS"
UNSTABLE_ALIAS="$(nvm_resolve_alias test-unstable-$i)"
[ "_$UNSTABLE_ALIAS" = "_v0.1.$i" ] \
|| die "'nvm_resolve_alias test-unstable-$i' was not v0.1.$i; got $UNSTABLE_ALIAS"
done
EXIT_CODE=$(nvm_resolve_alias nonexistent ; echo $?)
[ $EXIT_CODE = "2" ] || die "'nvm_resolve_alias nonexistent' did not return 2; got $EXIT_CODE"
STABLE="$(nvm_resolve_alias stable)"
[ "_$STABLE" = "_v0.0" ] || die "'nvm_resolve_alias stable' was not v0.0; got $STABLE"
NODE="$(nvm_resolve_alias node)"
[ "_$NODE" = "_stable" ] || die "'nvm_resolve_alias node' was not stable; got $NODE"
UNSTABLE="$(nvm_resolve_alias unstable)"
[ "_$UNSTABLE" = "_v0.1" ] || die "'nvm_resolve_alias unstable' was not v0.1; got $UNSTABLE"
IOJS="$(nvm_resolve_alias iojs)"
[ "_$IOJS" = "_iojs-v0.2" ] || die "'nvm_resolve_alias iojs' was not iojs-v0.2; got $IOJS"

View File

@@ -0,0 +1,35 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
EXIT_CODE=$(nvm_resolve_local_alias ; echo $?)
[ "_$EXIT_CODE" = "_1" ] || die "nvm_resolve_local_alias without an argument did not return 1; got $EXIT_CODE"
for i in $(seq 1 10)
do
STABLE_ALIAS="$(nvm_resolve_local_alias test-stable-$i)"
[ "_$STABLE_ALIAS" = "_v0.0.$i" ] \
|| die "'nvm_resolve_local_alias test-stable-$i' was not v0.0.$i; got $STABLE_ALIAS"
UNSTABLE_ALIAS="$(nvm_resolve_local_alias test-unstable-$i)"
[ "_$UNSTABLE_ALIAS" = "_v0.1.$i" ] \
|| die "'nvm_resolve_local_alias test-unstable-$i' was not v0.1.$i; got $UNSTABLE_ALIAS"
done
OUTPUT="$(nvm_resolve_local_alias nonexistent)"
EXIT_CODE=$(nvm_resolve_local_alias nonexistent > /dev/null 2>&1 ; echo $?)
[ "_$EXIT_CODE" = "_2" ] || die "'nvm_resolve_local_alias nonexistent' did not return 2; got $EXIT_CODE"
[ "_$OUTPUT" = "_" ] || die "'nvm_resolve_local_alias nonexistent' did not have empty output; got $OUTPUT"
STABLE="$(nvm_resolve_local_alias stable)"
[ "_$STABLE" = "_v0.0.10" ] || die "'nvm_resolve_local_alias stable' was not v0.0.10; got $STABLE"
NODE="$(nvm_resolve_local_alias node)"
[ "_$NODE" = "_v0.0.10" ] || die "'nvm_resolve_local_alias node' was not v0.0.10; got $NODE"
UNSTABLE="$(nvm_resolve_local_alias unstable)"
[ "_$UNSTABLE" = "_v0.1.10" ] || die "'nvm_resolve_local_alias unstable' was not v0.1.10; got $UNSTABLE"
IOJS="$(nvm_resolve_local_alias iojs)"
[ "_$IOJS" = "_iojs-v0.2.10" ] || die "'nvm_resolve_local_alias iojs' was not iojs-v0.2.10; got $IOJS"

11
test/fast/Aliases/setup Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/sh
for i in $(seq 1 10)
do
echo 0.0.$i > ../../../alias/test-stable-$i
mkdir -p ../../../v0.0.$i
echo 0.1.$i > ../../../alias/test-unstable-$i
mkdir -p ../../../v0.1.$i
echo 0.2.$i > ../../../alias/test-iojs-$i
mkdir -p ../../../versions/io.js/v0.2.$i
done

View File

@@ -1,6 +0,0 @@
#!/bin/sh
for i in $(seq 1 10)
do
echo v0.0.$i > ../../../alias/test$i
done

17
test/fast/Aliases/teardown Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/sh
for i in $(seq 1 10)
do
rm -f "../../../alias/test-stable-$i"
rm -rf "../../../v0.0.$i"
rm -f "../../../alias/test-unstable-$i"
rm -rf "../../../v0.1.$i"
rm -rf "../../../alias/test-iojs-$i"
rm -rf "../../../versions/io.js/v0.2.$i"
done
rm -f "../../../alias/stable"
rm -f "../../../alias/unstable"
rm -f "../../../alias/node"
rm -f "../../../alias/iojs"
rm -f "../../../alias/default"

View File

@@ -0,0 +1,27 @@
#!/bin/sh
mkdir -p ../../../v0.0.2
mkdir -p ../../../v0.0.20
mkdir -p ../../../versions/node/v0.12.0
. ../../../nvm.sh
die () { echo $@ ; exit 1; }
# The result should contain only the appropriate version numbers.
nvm which 0.0.2 || die "v0.0.2 not found"
NVM_BIN="$(nvm which 0.0.2)"
[ "_$NVM_BIN" = "_$(nvm_version_path v0.0.2)/bin/node" ] \
|| die "'nvm which 0.0.2' did not contain the correct path: got '$NVM_BIN'"
nvm which 0.0.20 || die "v0.0.20 not found"
NVM_BIN="$(nvm which 0.0.20)"
[ "_$NVM_BIN" = "_$(nvm_version_path v0.0.20)/bin/node" ] \
|| die "'nvm which 0.20.0' did not contain the correct path: got '$NVM_BIN'"
nvm which 0.12.0 || die "v0.0.20 not found"
NVM_BIN="$(nvm which 0.12.0)"
[ "_$NVM_BIN" = "_$(nvm_version_path v0.12.0)/bin/node" ] \
|| die "'nvm which 0.12.0' did not contain the correct path: got '$NVM_BIN'"

View File

@@ -0,0 +1,6 @@
#!/bin/sh
. ../../../nvm.sh
nvm which nonexistent_version
[ "_$?" = "_1" ]

View File

@@ -0,0 +1,3 @@
rmdir ../../../v0.0.2 >/dev/null 2>&1
rmdir ../../../v0.0.20 >/dev/null 2>&1
rmdir ../../../v0.12.0 >/dev/null 2>&1

View File

@@ -0,0 +1,21 @@
#!/bin/sh
mkdir ../../../v0.0.2
mkdir ../../../v0.0.20
. ../../../nvm.sh
die () { echo $@ ; exit 1; }
# The result should contain only the appropriate version numbers.
nvm ls 0.0.2 | grep 'v0.0.2' > /dev/null
if [ $? -eq 0 ]; then
echo '"nvm ls 0.0.2" contained v0.0.2'
fi
nvm ls 0.0.2 | grep 'v0.0.20' > /dev/null
if [ $? -eq 0 ]; then
die '"nvm ls 0.0.2" contained v0.0.20'
fi

View File

@@ -0,0 +1,7 @@
#!/bin/sh
. ../../../nvm.sh
nvm ls node_
[ "$?" = "3" ]

View File

@@ -0,0 +1,29 @@
#!/bin/sh
. ../../../nvm.sh
die () { echo $@ ; exit 1; }
mkdir ../../../v0.2.3
mkdir ../../../v0.3.3
EXPECTED_STABLE="$(nvm_print_implicit_alias local stable)"
STABLE_VERSION="$(nvm_version "$EXPECTED_STABLE")"
EXPECTED_UNSTABLE="$(nvm_print_implicit_alias local unstable)"
UNSTABLE_VERSION="$(nvm_version "$EXPECTED_UNSTABLE")"
nvm ls stable | \grep "$STABLE_VERSION" >/dev/null \
|| die "expected 'nvm ls stable' to give $STABLE_VERSION, got $(nvm ls stable)"
nvm ls unstable | \grep "$UNSTABLE_VERSION" >/dev/null \
|| die "expected 'nvm ls unstable' to give $UNSTABLE_VERSION, got $(nvm ls unstable)"
mkdir ../../../v0.1.2
nvm alias stable 0.1
nvm ls stable | \grep -v "$STABLE_VERSION" >/dev/null \
|| die "'nvm ls stable' contained $STABLE_VERSION instead of v0.1.2"
nvm ls stable | \grep v0.1.2 >/dev/null \
|| die "'nvm ls stable' did not contain v0.1.2"

View File

@@ -8,11 +8,17 @@ mkdir ../../../v0.0.9
mkdir ../../../v0.3.1
mkdir ../../../v0.3.3
mkdir ../../../v0.3.9
mkdir -p ../../../versions/node/v0.12.87
mkdir -p ../../../versions/node/v0.12.9
mkdir -p ../../../versions/io.js/v0.1.2
mkdir -p ../../../versions/io.js/v0.10.2
# The result should contain the version numbers.
nvm ls | grep v0.0.1 &&
nvm ls | grep v0.0.3 &&
nvm ls | grep v0.0.9 &&
nvm ls | grep v0.3.1 &&
nvm ls | grep v0.3.3 &&
nvm ls | grep v0.3.9
nvm ls | grep v0.0.1 >/dev/null &&
nvm ls | grep v0.0.3 >/dev/null &&
nvm ls | grep v0.0.9 >/dev/null &&
nvm ls | grep v0.3.1 >/dev/null &&
nvm ls | grep v0.3.3 >/dev/null &&
nvm ls | grep v0.3.9 >/dev/null &&
nvm ls | grep v0.12.87 >/dev/null &&
nvm ls | grep iojs-v0.1.2 >/dev/null

View File

@@ -2,7 +2,7 @@
mkdir ../../../v0.1.3
mkdir ../../../v0.2.3
mkdir ../../../versions
mkdir -p ../../../versions/node
. ../../../nvm.sh

View File

@@ -2,7 +2,7 @@
die () { echo $@ ; exit 1; }
mkdir -p ../../../versions/v0.12.1
mkdir -p ../../../versions/node/v0.12.1
mkdir ../../../v0.1.3
. ../../../nvm.sh

View File

@@ -1,12 +1,17 @@
rmdir ../../../v0.0.1 >/dev/null 2>&1
rmdir ../../../v0.0.2 >/dev/null 2>&1
rmdir ../../../v0.0.3 >/dev/null 2>&1
rmdir ../../../v0.0.9 >/dev/null 2>&1
rmdir ../../../v0.0.20 >/dev/null 2>&1
rmdir ../../../v0.1.2 >/dev/null 2>&1
rmdir ../../../v0.1.3 >/dev/null 2>&1
rmdir ../../../v0.2.3 >/dev/null 2>&1
rmdir ../../../v0.3.1 >/dev/null 2>&1
rmdir ../../../v0.3.3 >/dev/null 2>&1
rmdir ../../../v0.3.9 >/dev/null 2>&1
rmdir ../../../v0.20.3 >/dev/null 2>&1
rmdir ../../../versions >/dev/null 2>&1
unalias nvm_has_system_node >/dev/null 2>&1
rm -f ../../../alias/stable >/dev/null 2>&1
rm -f ../../../alias/unstable >/dev/null 2>&1

View File

@@ -7,8 +7,11 @@ die () { echo $@ ; exit 1; }
[ `expr $PATH : ".*v0.2.3/.*/bin"` = 0 ] || echo "WARNING: Unexpectedly found v0.2.3 already active" >&2
. ../../nvm.sh
nvm use v0.2.3 &&
[ `expr $PATH : ".*v0.2.3/.*/bin"` != 0 ] && [ `expr $NODE_PATH : ".*v0.2.3/.*/lib/node_modules"` != 0 ] || die "Failed to activate v0.2.3"
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
nvm deactivate &&
[ `expr $PATH : ".*v0.2.3/.*/bin"` = 0 ] && [ `expr $NODE_PATH : ".*v0.2.3/.*/lib/node_modules"` = 0 ] || die "Failed to deactivate v0.2.3"
nvm deactivate || die "Failed to deactivate v0.2.3"
[ `expr "$PATH" : ".*v0.2.3/.*/bin"` = 0 ] || die "PATH not cleaned properly"
[ `expr "$NODE_PATH" : ".*v0.2.3/.*/lib/node_modules"` = 0 ] || die "NODE_PATH not cleaned properly"

View File

@@ -1,31 +0,0 @@
#!/bin/sh
die () { echo $@ ; cleanup ; exit 1; }
cleanup () {
rm -rf ../../v0.10.4
}
mkdir ../../v0.10.4
. ../../nvm.sh
nvm deactivate >/dev/null 2>&1
INSTALL_ERROR_MSG="$(nvm install v0.10.5 --copy-packages-from=0.11 2>&1)"
EXPECTED_ERROR_MSG="If --copy-packages-from is provided, it must point to an installed version of node."
[ "~$INSTALL_ERROR_MSG" = "~$EXPECTED_ERROR_MSG" ] \
|| die ""nvm install --copy-packages" should fail when given an uninstalled version: expected '$EXPECTED_ERROR_MSG', got '$INSTALL_ERROR_MSG'"
INSTALL_EXIT_CODE="$(nvm install v0.10.5 --copy-packages-from=0.11 >/dev/null 2>&1; echo $?)"
[ "~$INSTALL_EXIT_CODE" = "~5" ] \
|| die ""nvm install --copy-packages" should exit with code 5 when given an uninstalled version, got $INSTALL_EXIT_CODE"
INSTALL_ERROR_MSG="$(nvm install v0.10.5 --copy-packages-from=0.10.5 2>&1)"
EXPECTED_ERROR_MSG="You can't copy global packages from the same version of node you're installing."
[ "~$INSTALL_ERROR_MSG" = "~$EXPECTED_ERROR_MSG" ] \
|| die ""nvm install --copy-packages" should fail when given the same version: expected '$EXPECTED_ERROR_MSG', got '$INSTALL_ERROR_MSG'"
INSTALL_EXIT_CODE="$(nvm install v0.10.5 --copy-packages-from=0.10.5 >/dev/null 2>&1; echo $?)"
[ "~$INSTALL_EXIT_CODE" = "~4" ] \
|| die ""nvm install --copy-packages" should exit with code 4 when given the same version, got $INSTALL_EXIT_CODE"

View File

@@ -0,0 +1,31 @@
#!/bin/sh
die () { echo $@ ; cleanup ; exit 1; }
cleanup () {
rm -rf ../../v0.10.4
}
mkdir ../../v0.10.4
. ../../nvm.sh
nvm deactivate >/dev/null 2>&1
INSTALL_ERROR_MSG="$(nvm install v0.10.5 --reinstall-packages-from=0.11 2>&1)"
EXPECTED_ERROR_MSG="If --reinstall-packages-from is provided, it must point to an installed version of node."
[ "~$INSTALL_ERROR_MSG" = "~$EXPECTED_ERROR_MSG" ] \
|| die ""nvm install --reinstall-packages-from" should fail when given an uninstalled version: expected '$EXPECTED_ERROR_MSG', got '$INSTALL_ERROR_MSG'"
INSTALL_EXIT_CODE="$(nvm install v0.10.5 --reinstall-packages-from=0.11 >/dev/null 2>&1; echo $?)"
[ "~$INSTALL_EXIT_CODE" = "~5" ] \
|| die ""nvm install --reinstall-packages-from" should exit with code 5 when given an uninstalled version, got $INSTALL_EXIT_CODE"
INSTALL_ERROR_MSG="$(nvm install v0.10.5 --reinstall-packages-from=0.10.5 2>&1)"
EXPECTED_ERROR_MSG="You can't reinstall global packages from the same version of node you're installing."
[ "~$INSTALL_ERROR_MSG" = "~$EXPECTED_ERROR_MSG" ] \
|| die ""nvm install --reinstall-packages-from" should fail when given the same version: expected '$EXPECTED_ERROR_MSG', got '$INSTALL_ERROR_MSG'"
INSTALL_EXIT_CODE="$(nvm install v0.10.5 --reinstall-packages-from=0.10.5 >/dev/null 2>&1; echo $?)"
[ "~$INSTALL_EXIT_CODE" = "~4" ] \
|| die ""nvm install --reinstall-packages-from" should exit with code 4 when given the same version, got $INSTALL_EXIT_CODE"

View File

@@ -0,0 +1,30 @@
#!/bin/sh
die () { echo $@ ; cleanup ; exit 1; }
cleanup() {
rm -rf ../../alias/foo
}
. ../../nvm.sh
echo 'foo' > ../../alias/foo
OUTPUT="$(nvm use foo 2>&1)"
EXPECTED_OUTPUT='The alias "foo" leads to an infinite loop. Aborting.'
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|| die "'nvm use foo' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"
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

@@ -0,0 +1,38 @@
#!/bin/sh
die () { echo $@ ; cleanup ; exit 1; }
cleanup() {
rm -rf ../../alias/foo
}
. ../../nvm.sh
echo 'foo' > ../../alias/foo
OUTPUT="$(nvm use foo 2>&1)"
EXPECTED_OUTPUT='The alias "foo" leads to an infinite loop. Aborting.'
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|| die "'nvm use foo' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"
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

@@ -5,9 +5,18 @@ die () { echo $@ ; exit 1; }
. ../../nvm.sh
nvm_has_system_node() { return 0; }
[ "$(nvm use system 2>&1 | tail -n1)" = "Now using system version of node: $(node -v)." ] || die "Could not use system version of node"
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 use system 2>&1 | tail -n1)" = "System version of node not found." ] || die "Did not report error, system node not found"
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

@@ -1,5 +1,6 @@
#!/bin/bash
export NVM_SYMLINK_CURRENT=true
. ../../nvm.sh
rm -rf ../../v0.10.29

View File

@@ -45,39 +45,40 @@ function isCurrentSymlinkPresent() {
NVM_SYMLINK_CURRENT=false
cleanup
runNvmUse
isCurrentSymlinkPresent && echo "Expected 'current' symlink not to be created when NVM_SYMLINK_CURRENT=false!"
isCurrentSymlinkPresent && echo >&2 "Expected 'current' symlink not to be created when NVM_SYMLINK_CURRENT=false!"
registerExpectedNoSymlink $?
NVM_SYMLINK_CURRENT=true
cleanup
runNvmUse
isCurrentSymlinkPresent || echo "Expected 'current' symlink to be created when NVM_SYMLINK_CURRENT=true!"
isCurrentSymlinkPresent || echo >&2 "Expected 'current' symlink to be created when NVM_SYMLINK_CURRENT=true!"
registerExpectedSymlink $?
NVM_SYMLINK_CURRENT=garbagevalue
cleanup
runNvmUse
isCurrentSymlinkPresent && echo "Expected 'current' symlink not to be created when NVM_SYMLINK_CURRENT contains a string!"
isCurrentSymlinkPresent && echo >&2 "Expected 'current' symlink not to be created when NVM_SYMLINK_CURRENT contains a string!"
registerExpectedNoSymlink $?
NVM_SYMLINK_CURRENT=0
cleanup
runNvmUse
isCurrentSymlinkPresent && echo "Expected 'current' symlink not to be created when NVM_SYMLINK_CURRENT=0!"
isCurrentSymlinkPresent && echo >&2 "Expected 'current' symlink not to be created when NVM_SYMLINK_CURRENT=0!"
registerExpectedNoSymlink $?
NVM_SYMLINK_CURRENT=1
cleanup
runNvmUse
isCurrentSymlinkPresent && echo "Expected 'current' symlink not to be created when NVM_SYMLINK_CURRENT=1!"
isCurrentSymlinkPresent && echo >&2 "Expected 'current' symlink not to be created when NVM_SYMLINK_CURRENT=1!"
registerExpectedNoSymlink $?
unset NVM_SYMLINK_CURRENT
cleanup
runNvmUse
isCurrentSymlinkPresent || echo "Expected 'current' symlink to be created when NVM_SYMLINK_CURRENT has been unset (default behaviour)!"
registerExpectedSymlink $?
isCurrentSymlinkPresent && echo >&2 "Expected 'current' symlink not to be created when NVM_SYMLINK_CURRENT has been unset (default behaviour)!"
registerExpectedNoSymlink $?
cleanup
[ ${TEST_FAILED} -ne 0 ] && echo "${TEST_COUNT} tested, ${TEST_PASSED} passed, ${TEST_FAILED} failed" && exit 1 || true

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,9 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
[ "_$(nvm_add_iojs_prefix 1)" = "_iojs-v1" ] || die '"nvm_add_iojs_prefix 1" did not return "iojs-v1"'
[ "_$(nvm_add_iojs_prefix iojs-1)" = "_iojs-v1" ] || die '"nvm_add_iojs_prefix iojs-1" did not return "iojs-v1"'
[ "_$(nvm_add_iojs_prefix iojs-1.2.3)" = "_iojs-v1.2.3" ] || die '"nvm_add_iojs_prefix iojs-1.2.3" did not return "iojs-v1.2.3"'

33
test/fast/Unit tests/nvm_alias Executable file
View File

@@ -0,0 +1,33 @@
#!/bin/sh
die () { echo $@ ; cleanup ; exit 1; }
cleanup () {
rm -rf ../../../alias/test
}
. ../../../nvm.sh
OUTPUT="$(nvm_alias 2>&1)"
EXPECTED_OUTPUT='An alias is required.'
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_alias' produced wrong output; got $OUTPUT"
EXIT_CODE="$(nvm_alias >/dev/null 2>&1 ; echo $?)"
[ "_$EXIT_CODE" = "_1" ] || die "'nvm_alias' exited with $EXIT_CODE, expected 1"
rm -rf ../../../alias/nonexistent
OUTPUT="$(nvm_alias nonexistent 2>&1)"
EXPECTED_OUTPUT='Alias does not exist.'
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_alias nonexistent' produced wrong output; got $OUTPUT"
EXIT_CODE="$(nvm_alias nonexistent >/dev/null 2>&1 ; echo $?)"
[ "_$EXIT_CODE" = "_2" ] || die "'nvm_alias nonexistent' exited with $EXIT_CODE, expected 2"
EXPECTED_OUTPUT="0.10"
nvm alias test "$EXPECTED_OUTPUT" || die "'nvm alias test $EXPECTED_OUTPUT' failed"
OUTPUT="$(nvm_alias test)"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_alias test' produced wrong output; got $OUTPUT"
cleanup

View File

@@ -0,0 +1,8 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
[ "_$(nvm_alias_path)" = "_$NVM_DIR/alias" ] || die "nvm_alias_path did not requrn correct location"

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

@@ -0,0 +1,13 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
EXPECTED_OUTPUT="nvm_ensure_default_set: a version is required"
OUTPUT="$(nvm_ensure_default_set 2>&1 >/dev/null)"
EXIT_CODE="$?"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_ensure_default_set' did not output "$EXPECTED_OUTPUT", got "$OUTPUT""
[ "_$EXIT_CODE" = "_1" ] || die "'nvm_ensure_default_set' did not exit with 1, got "$EXIT_CODE""
# see test/fast/Aliases for remaining nvm_ensure_default_set tests

View File

@@ -0,0 +1,30 @@
#!/bin/sh
die () { echo $@ ; cleanup ; exit 1; }
cleanup () {
rm -rf "$(nvm_version_path v0.1.2)"
}
. ../../../nvm.sh
mkdir -p "$(nvm_version_path v0.1.2)"
OUTPUT="$(nvm_ensure_version_installed foo 2>&1)"
EXIT_CODE=$?
EXPECTED_OUTPUT='N/A: version "foo" is not yet installed'
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "expected 'nvm_ensure_version_installed foo' to give $EXPECTED_OUTPUT, got $OUTPUT"
[ "_$EXIT_CODE" = "_1" ] || die "expected 'nvm_ensure_version_installed foo' to exit with 1, got $EXIT_CODE"
OUTPUT="$(nvm_ensure_version_installed 0.1)"
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,12 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
[ "_$(nvm_ensure_version_prefix 1)" = "_v1" ] || die '"nvm_ensure_version_prefix 1" did not return "v1"'
[ "_$(nvm_ensure_version_prefix v1)" = "_v1" ] || die '"nvm_ensure_version_prefix v1" did not return "v1"'
[ "_$(nvm_ensure_version_prefix foo)" = "_foo" ] || die '"nvm_ensure_version_prefix foo" did not return "foo"'
[ "_$(nvm_ensure_version_prefix iojs-1)" = "_iojs-v1" ] || die '"nvm_ensure_version_prefix iojs-1" did not return "iojs-v1"'
[ "_$(nvm_ensure_version_prefix iojs-v1)" = "_iojs-v1" ] || die '"nvm_ensure_version_prefix iojs-v1" did not return "iojs-v1"'

View File

@@ -0,0 +1,14 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
OUTPUT="$(nvm_format_version 0.1.2)"
EXPECTED_OUTPUT="v0.1.2"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_format_version 0.1.2 did not return $EXPECTED_OUTPUT; got $OUTPUT"
OUTPUT="$(nvm_format_version 0.1)"
EXPECTED_OUTPUT="v0.1.0"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_format_version 0.1.0 did not return $EXPECTED_OUTPUT; got $OUTPUT"

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,20 @@
#!/bin/sh
die () { echo $@ ; cleanup ; exit 1; }
cleanup() {
unset -f nvm_has
}
. ../../../nvm.sh
nvm_has() { return 1 ; }
OUTPUT="$(nvm_get_latest 2>&1)"
EXIT_CODE="$(nvm_get_latest >/dev/null 2>&1 ; echo $?)"
[ "_$OUTPUT" = "_nvm needs curl or wget to proceed." ] \
|| die "no curl/wget did not report correct error message, got '$OUTPUT'"
[ "_$EXIT_CODE" = "_1" ] \
|| die "no curl/wget did not exit with code 1, got $EXIT_CODE"
cleanup

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,31 @@
#!/bin/sh
cleanup () {
rm ../../../versions/io.js/v0.1.2/node
rm ../../../versions/io.js/v0.1.2/iojs
rmdir ../../../versions/io.js/v0.1.2
}
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
mkdir ../../../versions/io.js/v0.1.2
touch ../../../versions/io.js/v0.1.2/node
touch ../../../versions/io.js/v0.1.2/iojs
nvm use iojs-v0.1.2
if command -v iojs; then
nvm_has_system_iojs
else
! nvm_has_system_iojs
fi
nvm deactivate /dev/null 2>&1
if command -v iojs; then
nvm_has_system_iojs
else
! nvm_has_system_iojs
fi

View File

@@ -0,0 +1,7 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
[ "$(nvm_iojs_prefix)" = "iojs" ] || die '"nvm_iojs_prefix" did not return the string "iojs". why did this fail?!'

View File

@@ -0,0 +1,20 @@
#!/bin/sh
cleanup () { unalias foo; unalias grep; }
die () { echo $@ ; cleanup ; exit 1; }
. ../../../nvm.sh
alias foo='bar'
nvm_is_alias foo || die '"nvm_is_alias foo" was not true'
! nvm_is_alias nvm_is_alias || die '"nvm_is_alias nvm_is_alias was not false'
alias grep='grep'
unalias grep || die '"unalias grep" failed'
! nvm_is_alias grep || die '"nvm_is_alias grep" with unaliased grep was not false'
alias grep='grep'
nvm_is_alias grep || die '"nvm_is_alias grep" with aliased grep was not true'
cleanup

View File

@@ -0,0 +1,10 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
nvm_is_iojs_version 'iojs-' || die '"nvm_is_iojs_version iojs- was not true'
nvm_is_iojs_version 'iojs-foo' || die '"nvm_is_iojs_version iojs- was not true'
! nvm_is_iojs_version 'iojs' || die '"nvm_is_iojs_version iojs was not false'
! nvm_is_iojs_version 'v1.0.0' || die '"nvm_is_iojs_version v1.0.0" was not false'

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

@@ -0,0 +1,13 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
nvm_is_valid_version 0.1.2 || die "nvm_is_valid_version 0.1.2 did not return 0"
nvm_is_valid_version foo && die "nvm_is_valid_version foo did not return 1"
nvm_is_valid_version iojs-1 || die "nvm_is_valid_version iojs-1 did not return 0"
nvm_is_valid_version iojs || die "nvm_is_valid_version iojs did not return 0"
nvm_is_valid_version node || die "nvm_is_valid_version node did not return 0"
nvm_is_valid_version stable || die "nvm_is_valid_version stable did not return 0"
nvm_is_valid_version unstable || die "nvm_is_valid_version unstable did not return 0"

View File

@@ -1,19 +1,26 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
TEST_PWD=$(pwd)
TEST_DIR="$TEST_PWD/nvm_ls_current_tmp"
cleanup() { rm -rf "$TEST_DIR"; unset -f return_zero; alias node='node' ; unalias node; }
die () { echo $@ ; cleanup ; exit 1; }
. ../../../nvm.sh
return_zero () { return 0; }
[ "$(nvm deactivate > /dev/null 2>&1 ; nvm_ls_current)" = "system" ] || die 'when deactivated, did not return "system"'
if nvm_has_system_node || nvm_has_system_iojs; then
EXPECTED_SYSTEM_NODE="system"
else
EXPECTED_SYSTEM_NODE="none"
fi
[ "_$(nvm deactivate > /dev/null 2>&1 ; nvm_ls_current)" = "_$EXPECTED_SYSTEM_NODE" ] || die "when deactivated, did not return $EXPECTED_SYSTEM_NODE"
TEST_PWD=$(pwd)
TEST_DIR="$TEST_PWD/nvm_ls_current_tmp"
rm -rf "$TEST_DIR"
mkdir "$TEST_DIR"
ln -s "$(which which)" "$TEST_DIR/which"
ln -s "$(which dirname)" "$TEST_DIR/dirname"
ln -s "$(command which which)" "$TEST_DIR/which"
ln -s "$(command which dirname)" "$TEST_DIR/dirname"
[ "$(PATH="$TEST_DIR" nvm_ls_current)" = "none" ] || die 'when node not installed, nvm_ls_current did not return "none"'
[ "@$(PATH="$TEST_DIR" nvm_ls_current 2> /dev/stdout 1> /dev/null)@" = "@@" ] || die 'when node not installed, nvm_ls_current returned error output'
@@ -24,5 +31,7 @@ chmod a+x "$TEST_DIR/node"
[ "$(alias nvm_tree_contains_path='return_zero' && PATH="$TEST_DIR" nvm_ls_current)" = "VERSION FOO!" ] || die 'when activated, did not return nvm node version'
rm -rf "$TEST_DIR"
alias node='node --harmony'
[ "$(alias nvm_tree_contains_path='return_zero' && PATH="$TEST_DIR" nvm_ls_current)" = "VERSION FOO!" ] || die 'when activated and node aliased, did not return nvm node version'
cleanup

View File

@@ -0,0 +1,485 @@
#!/bin/sh
die () { echo $@ ; cleanup ; exit 1; }
cleanup() {
unset -f nvm_download
}
. ../../../nvm.sh
# sample output at the time the test was written
nvm_download() {
echo 'foo "v0.10.0'
echo 'foo "v0.10.0'
echo 'foo "v0.10.1'
echo 'foo "v0.10.1'
echo 'foo "v0.10.10'
echo 'foo "v0.10.10'
echo 'foo "v0.10.11'
echo 'foo "v0.10.11'
echo 'foo "v0.10.12'
echo 'foo "v0.10.12'
echo 'foo "v0.10.13'
echo 'foo "v0.10.13'
echo 'foo "v0.10.14'
echo 'foo "v0.10.14'
echo 'foo "v0.10.15'
echo 'foo "v0.10.15'
echo 'foo "v0.10.16'
echo 'foo "v0.10.16'
echo 'foo "v0.10.16'
echo 'foo "v0.10.16'
echo 'foo "v0.10.17'
echo 'foo "v0.10.17'
echo 'foo "v0.10.18'
echo 'foo "v0.10.18'
echo 'foo "v0.10.19'
echo 'foo "v0.10.19'
echo 'foo "v0.10.2'
echo 'foo "v0.10.2'
echo 'foo "v0.10.20'
echo 'foo "v0.10.20'
echo 'foo "v0.10.21'
echo 'foo "v0.10.21'
echo 'foo "v0.10.22'
echo 'foo "v0.10.22'
echo 'foo "v0.10.23'
echo 'foo "v0.10.23'
echo 'foo "v0.10.24'
echo 'foo "v0.10.24'
echo 'foo "v0.10.25'
echo 'foo "v0.10.25'
echo 'foo "v0.10.26'
echo 'foo "v0.10.26'
echo 'foo "v0.10.27'
echo 'foo "v0.10.27'
echo 'foo "v0.10.28'
echo 'foo "v0.10.28'
echo 'foo "v0.10.29'
echo 'foo "v0.10.29'
echo 'foo "v0.10.3'
echo 'foo "v0.10.3'
echo 'foo "v0.10.30'
echo 'foo "v0.10.30'
echo 'foo "v0.10.31'
echo 'foo "v0.10.31'
echo 'foo "v0.10.32'
echo 'foo "v0.10.32'
echo 'foo "v0.10.4'
echo 'foo "v0.10.4'
echo 'foo "v0.10.5'
echo 'foo "v0.10.5'
echo 'foo "v0.10.6'
echo 'foo "v0.10.6'
echo 'foo "v0.10.7'
echo 'foo "v0.10.7'
echo 'foo "v0.10.8'
echo 'foo "v0.10.8'
echo 'foo "v0.10.9'
echo 'foo "v0.10.9'
echo 'foo "v0.11.0'
echo 'foo "v0.11.0'
echo 'foo "v0.11.1'
echo 'foo "v0.11.1'
echo 'foo "v0.11.10'
echo 'foo "v0.11.10'
echo 'foo "v0.11.11'
echo 'foo "v0.11.11'
echo 'foo "v0.11.12'
echo 'foo "v0.11.12'
echo 'foo "v0.11.13'
echo 'foo "v0.11.13'
echo 'foo "v0.11.14'
echo 'foo "v0.11.14'
echo 'foo "v0.11.2'
echo 'foo "v0.11.2'
echo 'foo "v0.11.3'
echo 'foo "v0.11.3'
echo 'foo "v0.11.4'
echo 'foo "v0.11.4'
echo 'foo "v0.11.5'
echo 'foo "v0.11.5'
echo 'foo "v0.11.6'
echo 'foo "v0.11.6'
echo 'foo "v0.11.7'
echo 'foo "v0.11.7'
echo 'foo "v0.11.8'
echo 'foo "v0.11.8'
echo 'foo "v0.11.9'
echo 'foo "v0.11.9'
echo 'foo "v0.5.1'
echo 'foo "v0.5.1'
echo 'foo "v0.5.10'
echo 'foo "v0.5.10'
echo 'foo "v0.5.2'
echo 'foo "v0.5.2'
echo 'foo "v0.5.3'
echo 'foo "v0.5.3'
echo 'foo "v0.5.4'
echo 'foo "v0.5.4'
echo 'foo "v0.5.5'
echo 'foo "v0.5.5'
echo 'foo "v0.5.6'
echo 'foo "v0.5.6'
echo 'foo "v0.5.7'
echo 'foo "v0.5.7'
echo 'foo "v0.5.8'
echo 'foo "v0.5.8'
echo 'foo "v0.5.9'
echo 'foo "v0.5.9'
echo 'foo "v0.6.0'
echo 'foo "v0.6.0'
echo 'foo "v0.6.1'
echo 'foo "v0.6.1'
echo 'foo "v0.6.10'
echo 'foo "v0.6.10'
echo 'foo "v0.6.11'
echo 'foo "v0.6.11'
echo 'foo "v0.6.12'
echo 'foo "v0.6.12'
echo 'foo "v0.6.13'
echo 'foo "v0.6.13'
echo 'foo "v0.6.14'
echo 'foo "v0.6.14'
echo 'foo "v0.6.15'
echo 'foo "v0.6.15'
echo 'foo "v0.6.16'
echo 'foo "v0.6.16'
echo 'foo "v0.6.17'
echo 'foo "v0.6.17'
echo 'foo "v0.6.18'
echo 'foo "v0.6.18'
echo 'foo "v0.6.19'
echo 'foo "v0.6.19'
echo 'foo "v0.6.2'
echo 'foo "v0.6.2'
echo 'foo "v0.6.20'
echo 'foo "v0.6.20'
echo 'foo "v0.6.21'
echo 'foo "v0.6.21'
echo 'foo "v0.6.3'
echo 'foo "v0.6.3'
echo 'foo "v0.6.4'
echo 'foo "v0.6.4'
echo 'foo "v0.6.5'
echo 'foo "v0.6.5'
echo 'foo "v0.6.6'
echo 'foo "v0.6.6'
echo 'foo "v0.6.7'
echo 'foo "v0.6.7'
echo 'foo "v0.6.8'
echo 'foo "v0.6.8'
echo 'foo "v0.6.9'
echo 'foo "v0.6.9'
echo 'foo "v0.7.0'
echo 'foo "v0.7.0'
echo 'foo "v0.7.1'
echo 'foo "v0.7.1'
echo 'foo "v0.7.10'
echo 'foo "v0.7.10'
echo 'foo "v0.7.11'
echo 'foo "v0.7.11'
echo 'foo "v0.7.12'
echo 'foo "v0.7.12'
echo 'foo "v0.7.2'
echo 'foo "v0.7.2'
echo 'foo "v0.7.3'
echo 'foo "v0.7.3'
echo 'foo "v0.7.4'
echo 'foo "v0.7.4'
echo 'foo "v0.7.5'
echo 'foo "v0.7.5'
echo 'foo "v0.7.6'
echo 'foo "v0.7.6'
echo 'foo "v0.7.7'
echo 'foo "v0.7.7'
echo 'foo "v0.7.8'
echo 'foo "v0.7.8'
echo 'foo "v0.7.9'
echo 'foo "v0.7.9'
echo 'foo "v0.8.0'
echo 'foo "v0.8.0'
echo 'foo "v0.8.1'
echo 'foo "v0.8.1'
echo 'foo "v0.8.10'
echo 'foo "v0.8.10'
echo 'foo "v0.8.11'
echo 'foo "v0.8.11'
echo 'foo "v0.8.12'
echo 'foo "v0.8.12'
echo 'foo "v0.8.13'
echo 'foo "v0.8.13'
echo 'foo "v0.8.14'
echo 'foo "v0.8.14'
echo 'foo "v0.8.15'
echo 'foo "v0.8.15'
echo 'foo "v0.8.16'
echo 'foo "v0.8.16'
echo 'foo "v0.8.17'
echo 'foo "v0.8.17'
echo 'foo "v0.8.18'
echo 'foo "v0.8.18'
echo 'foo "v0.8.19'
echo 'foo "v0.8.19'
echo 'foo "v0.8.2'
echo 'foo "v0.8.2'
echo 'foo "v0.8.20'
echo 'foo "v0.8.20'
echo 'foo "v0.8.21'
echo 'foo "v0.8.21'
echo 'foo "v0.8.22'
echo 'foo "v0.8.22'
echo 'foo "v0.8.23'
echo 'foo "v0.8.23'
echo 'foo "v0.8.24'
echo 'foo "v0.8.24'
echo 'foo "v0.8.25'
echo 'foo "v0.8.25'
echo 'foo "v0.8.26'
echo 'foo "v0.8.26'
echo 'foo "v0.8.27'
echo 'foo "v0.8.27'
echo 'foo "v0.8.28'
echo 'foo "v0.8.28'
echo 'foo "v0.8.3'
echo 'foo "v0.8.3'
echo 'foo "v0.8.4'
echo 'foo "v0.8.4'
echo 'foo "v0.8.5'
echo 'foo "v0.8.5'
echo 'foo "v0.8.6'
echo 'foo "v0.8.6'
echo 'foo "v0.8.7'
echo 'foo "v0.8.7'
echo 'foo "v0.8.8'
echo 'foo "v0.8.8'
echo 'foo "v0.8.9'
echo 'foo "v0.8.9'
echo 'foo "v0.9.0'
echo 'foo "v0.9.0'
echo 'foo "v0.9.1'
echo 'foo "v0.9.1'
echo 'foo "v0.9.10'
echo 'foo "v0.9.10'
echo 'foo "v0.9.11'
echo 'foo "v0.9.11'
echo 'foo "v0.9.12'
echo 'foo "v0.9.12'
echo 'foo "v0.9.2'
echo 'foo "v0.9.2'
echo 'foo "v0.9.3'
echo 'foo "v0.9.3'
echo 'foo "v0.9.4'
echo 'foo "v0.9.4'
echo 'foo "v0.9.5'
echo 'foo "v0.9.5'
echo 'foo "v0.9.6'
echo 'foo "v0.9.6'
echo 'foo "v0.9.7'
echo 'foo "v0.9.7'
echo 'foo "v0.9.8'
echo 'foo "v0.9.8'
echo 'foo "v0.9.9'
echo 'foo "v0.9.9'
echo 'foo "v0.1.100'
echo 'foo "v0.1.100'
echo 'foo "v0.1.101'
echo 'foo "v0.1.101'
echo 'foo "v0.1.102'
echo 'foo "v0.1.102'
echo 'foo "v0.1.103'
echo 'foo "v0.1.103'
echo 'foo "v0.1.104'
echo 'foo "v0.1.104'
echo 'foo "v0.1.14'
echo 'foo "v0.1.14'
echo 'foo "v0.1.15'
echo 'foo "v0.1.15'
echo 'foo "v0.1.16'
echo 'foo "v0.1.16'
echo 'foo "v0.1.17'
echo 'foo "v0.1.17'
echo 'foo "v0.1.18'
echo 'foo "v0.1.18'
echo 'foo "v0.1.19'
echo 'foo "v0.1.19'
echo 'foo "v0.1.20'
echo 'foo "v0.1.20'
echo 'foo "v0.1.21'
echo 'foo "v0.1.21'
echo 'foo "v0.1.22'
echo 'foo "v0.1.22'
echo 'foo "v0.1.23'
echo 'foo "v0.1.23'
echo 'foo "v0.1.24'
echo 'foo "v0.1.24'
echo 'foo "v0.1.25'
echo 'foo "v0.1.25'
echo 'foo "v0.1.26'
echo 'foo "v0.1.26'
echo 'foo "v0.1.27'
echo 'foo "v0.1.27'
echo 'foo "v0.1.28'
echo 'foo "v0.1.28'
echo 'foo "v0.1.29'
echo 'foo "v0.1.29'
echo 'foo "v0.1.30'
echo 'foo "v0.1.30'
echo 'foo "v0.1.31'
echo 'foo "v0.1.31'
echo 'foo "v0.1.32'
echo 'foo "v0.1.32'
echo 'foo "v0.1.33'
echo 'foo "v0.1.33'
echo 'foo "v0.1.90'
echo 'foo "v0.1.90'
echo 'foo "v0.1.91'
echo 'foo "v0.1.91'
echo 'foo "v0.1.92'
echo 'foo "v0.1.92'
echo 'foo "v0.1.93'
echo 'foo "v0.1.93'
echo 'foo "v0.1.94'
echo 'foo "v0.1.94'
echo 'foo "v0.1.95'
echo 'foo "v0.1.95'
echo 'foo "v0.1.96'
echo 'foo "v0.1.96'
echo 'foo "v0.1.97'
echo 'foo "v0.1.97'
echo 'foo "v0.1.98'
echo 'foo "v0.1.98'
echo 'foo "v0.1.99'
echo 'foo "v0.1.99'
echo 'foo "v0.10.14'
echo 'foo "v0.10.14'
echo 'foo "v0.2.0'
echo 'foo "v0.2.0'
echo 'foo "v0.2.1'
echo 'foo "v0.2.1'
echo 'foo "v0.2.2'
echo 'foo "v0.2.2'
echo 'foo "v0.2.3'
echo 'foo "v0.2.3'
echo 'foo "v0.2.4'
echo 'foo "v0.2.4'
echo 'foo "v0.2.5'
echo 'foo "v0.2.5'
echo 'foo "v0.2.6'
echo 'foo "v0.2.6'
echo 'foo "v0.3.0'
echo 'foo "v0.3.0'
echo 'foo "v0.3.1'
echo 'foo "v0.3.1'
echo 'foo "v0.3.2'
echo 'foo "v0.3.2'
echo 'foo "v0.3.3'
echo 'foo "v0.3.3'
echo 'foo "v0.3.4'
echo 'foo "v0.3.4'
echo 'foo "v0.3.5'
echo 'foo "v0.3.5'
echo 'foo "v0.3.6'
echo 'foo "v0.3.6'
echo 'foo "v0.3.7'
echo 'foo "v0.3.7'
echo 'foo "v0.3.8'
echo 'foo "v0.3.8'
echo 'foo "v0.4.0'
echo 'foo "v0.4.0'
echo 'foo "v0.4.1'
echo 'foo "v0.4.1'
echo 'foo "v0.4.10'
echo 'foo "v0.4.10'
echo 'foo "v0.4.11'
echo 'foo "v0.4.11'
echo 'foo "v0.4.12'
echo 'foo "v0.4.12'
echo 'foo "v0.4.2'
echo 'foo "v0.4.2'
echo 'foo "v0.4.3'
echo 'foo "v0.4.3'
echo 'foo "v0.4.4'
echo 'foo "v0.4.4'
echo 'foo "v0.4.5'
echo 'foo "v0.4.5'
echo 'foo "v0.4.6'
echo 'foo "v0.4.6'
echo 'foo "v0.4.7'
echo 'foo "v0.4.7'
echo 'foo "v0.4.8'
echo 'foo "v0.4.8'
echo 'foo "v0.4.9'
echo 'foo "v0.4.9'
echo 'foo "v0.5.0'
echo 'foo "v0.5.0'
echo 'foo "v0.6.1'
echo 'foo "v0.6.1'
echo 'foo "v0.6.10'
echo 'foo "v0.6.10'
echo 'foo "v0.6.11'
echo 'foo "v0.6.11'
echo 'foo "v0.6.12'
echo 'foo "v0.6.12'
echo 'foo "v0.6.13'
echo 'foo "v0.6.13'
echo 'foo "v0.6.2'
echo 'foo "v0.6.2'
echo 'foo "v0.6.3'
echo 'foo "v0.6.3'
echo 'foo "v0.6.4'
echo 'foo "v0.6.4'
echo 'foo "v0.6.5'
echo 'foo "v0.6.5'
echo 'foo "v0.6.6'
echo 'foo "v0.6.6'
echo 'foo "v0.6.7'
echo 'foo "v0.6.7'
echo 'foo "v0.6.8'
echo 'foo "v0.6.8'
echo 'foo "v0.6.9'
echo 'foo "v0.6.9'
}
OUTPUT="$(nvm_ls_remote foo)"
EXIT_CODE="$(nvm_ls_remote foo >/dev/null 2>&1 ; echo $?)"
[ "_$OUTPUT" = "_N/A" ] || die "nonexistent version did not report N/A"
[ "_$EXIT_CODE" = "_3" ] || die "nonexistent version did not exit with code 3, got $EXIT_CODE"
OUTPUT="$(nvm_ls_remote)"
EXPECTED_OUTPUT="$(nvm_download | \egrep -o 'v[0-9]+\.[0-9]+\.[0-9]+' | sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n)"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "bare nvm_ls_remote did not output expected sorted versions; got $(echo "$OUTPUT") expected $(echo "$EXPECTED_OUTPUT")"
OUTPUT="$(nvm_ls_remote 0.3)"
EXPECTED_OUTPUT="v0.3.0
v0.3.1
v0.3.2
v0.3.3
v0.3.4
v0.3.5
v0.3.6
v0.3.7
v0.3.8"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote 0.3 did not output 0.3.x versions; got $OUTPUT"
# Sanity checks
OUTPUT="$(nvm_print_implicit_alias remote stable)"
EXPECTED_OUTPUT="0.10"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_print_implicit_alias remote stable did not output $EXPECTED_OUTPUT; got $OUTPUT"
OUTPUT="$(nvm_print_implicit_alias remote unstable)"
EXPECTED_OUTPUT="0.11"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_print_implicit_alias remote unstable did not output $EXPECTED_OUTPUT; got $OUTPUT"
OUTPUT="$(nvm_ls_remote stable)"
EXPECTED_OUTPUT="v0.10.32"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote stable did not output $EXPECTED_OUTPUT; got $OUTPUT"
OUTPUT="$(nvm_ls_remote unstable)"
EXPECTED_OUTPUT="v0.11.14"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote unstable did not output $EXPECTED_OUTPUT; got $OUTPUT"
cleanup

View File

@@ -0,0 +1,34 @@
#!/bin/sh
die () { echo $@ ; cleanup ; exit 1; }
cleanup() {
unset -f nvm_download
}
. ../../../nvm.sh
# sample output at the time the test was written
nvm_download() {
echo 'version date files npm v8 uv zlib openssl modules'
echo 'v1.0.1 2015-01-14 linux-armv7l,linux-x64,linux-x86,osx-x64-tar,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi'
echo 'v1.0.0 2015-01-14 linux-armv7l,linux-x64,linux-x86,osx-x64-tar,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi'
}
OUTPUT="$(nvm_ls_remote_iojs foo)"
EXIT_CODE="$(nvm_ls_remote_iojs foo >/dev/null 2>&1 ; echo $?)"
[ "_$OUTPUT" = "_N/A" ] || die "nonexistent version did not report N/A"
[ "_$EXIT_CODE" = "_3" ] || die "nonexistent version did not exit with code 3, got $EXIT_CODE"
OUTPUT="$(nvm_ls_remote_iojs)"
EXPECTED_OUTPUT="$(nvm_download | \egrep -o 'v[0-9]+\.[0-9]+\.[0-9]+' | sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n | sed -e 's/^/iojs-/')"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "bare nvm_ls_remote_iojs did not output expected sorted versions; got $(echo "$OUTPUT") expected $(echo "$EXPECTED_OUTPUT")"
OUTPUT="$(nvm_ls_remote_iojs 1.0)"
EXPECTED_OUTPUT="iojs-v1.0.0
iojs-v1.0.1"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote_iojs 1.0 did not output 1.0.x versions; got $OUTPUT"
cleanup

View File

@@ -0,0 +1,7 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
[ "$(nvm_node_prefix)" = "node" ] || die '"nvm_node_prefix" did not return the string "node". why did this fail?!'

View File

@@ -5,13 +5,17 @@ die () { echo $@ ; exit 1; }
. ../../../nvm.sh
[ "~$(nvm_num_version_groups)" = "~0" ] || die "no args should give 0"
[ "~$(nvm_num_version_groups v)" = "~0" ] || die "just "v" should give 0"
[ "~$(nvm_num_version_groups .)" = "~0" ] || die "just "." should give 0"
[ "~$(nvm_num_version_groups a)" = "~1" ] || die "one letter should give 1"
[ "~$(nvm_num_version_groups 1)" = "~1" ] || die "1 should give 1"
[ "~$(nvm_num_version_groups 1.)" = "~1" ] || die "1. should give 1"
[ "~$(nvm_num_version_groups v1)" = "~1" ] || die "v1 should give 1"
[ "~$(nvm_num_version_groups v1.)" = "~1" ] || die "v1. should give 1"
[ "~$(nvm_num_version_groups 1.2)" = "~2" ] || die "1.2 should give 2"
[ "~$(nvm_num_version_groups 1.2.)" = "~2" ] || die "1.2. should give 2"
[ "~$(nvm_num_version_groups v1.2)" = "~2" ] || die "v1.2 should give 2"
[ "~$(nvm_num_version_groups v1.2.)" = "~2" ] || die "v1.2. should give 2"

View File

@@ -0,0 +1,26 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
EXPECTED_FIRST_MSG="nvm_print_implicit_alias must be specified with local or remote as the first argument."
[ "_$(nvm_print_implicit_alias 2>&1)" = "_$EXPECTED_FIRST_MSG" ] \
|| die "nvm_print_implicit_alias did not require local|remote as first argument"
[ "_$(nvm_print_implicit_alias foo 2>&1)" = "_$EXPECTED_FIRST_MSG" ] \
|| die "nvm_print_implicit_alias did not require local|remote as first argument"
FIRST_EXIT_CODE="$(nvm_print_implicit_alias > /dev/null 2>&1 ; echo $?)"
[ "_$FIRST_EXIT_CODE" = "_1" ] \
|| die "nvm_print_implicit_alias without local|remote had wrong exit code: expected 1, got $FIRST_EXIT_CODE"
EXPECTED_SECOND_MSG="Only implicit aliases 'stable', 'unstable', 'iojs', and 'node' are supported."
[ "_$(nvm_print_implicit_alias local 2>&1)" = "_$EXPECTED_SECOND_MSG" ] \
|| die "nvm_print_implicit_alias did not require stable|unstable|iojs|node as second argument"
[ "_$(nvm_print_implicit_alias local foo 2>&1)" = "_$EXPECTED_SECOND_MSG" ] \
|| die "nvm_print_implicit_alias did not require stable|unstable|iojs|node as second argument"
SECOND_EXIT_CODE="$(nvm_print_implicit_alias local > /dev/null 2>&1 ; echo $?)"
[ "_$SECOND_EXIT_CODE" = "_2" ] \
|| die "nvm_print_implicit_alias without stable|unstable|iojs|node had wrong exit code: expected 2, got $SECOND_EXIT_CODE"

View File

@@ -0,0 +1,105 @@
#!/bin/sh
die () { echo $@ ; cleanup ; exit 1; }
cleanup() {
rm -rf ../../../v0.2.3
rm -rf ../../../v0.3.4
rm -rf ../../../v0.4.6
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
}
. ../../../nvm.sh
mkdir ../../../v0.2.3
mkdir ../../../v0.3.4
mkdir ../../../v0.4.6
mkdir ../../../v0.5.7
mkdir ../../../v0.7.7
mkdir -p ../../../versions/io.js/v0.98.0
LATEST_STABLE="$(nvm_print_implicit_alias local stable)"
[ "_$LATEST_STABLE" = "_0.4" ] || die "local stable is not latest even minor: expected 0.4, got $LATEST_STABLE"
LATEST_NODE="$(nvm_print_implicit_alias local node)"
[ "_$LATEST_NODE" = "_stable" ] || die "local node is not stable: expected stable, got $LATEST_NODE"
LATEST_UNSTABLE="$(nvm_print_implicit_alias local unstable)"
[ "_$LATEST_UNSTABLE" = "_0.7" ] || die "local unstable is not latest odd minor: expected 0.7, got $LATEST_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"
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"
}
nvm_ls_remote_iojs() {
echo "iojs-v0.1.0"
echo "iojs-v0.1.1"
echo "iojs-v0.7.8"
echo "iojs-v0.98.5"
echo "iojs-v0.99.0"
}
LATEST_STABLE="$(nvm_print_implicit_alias remote stable)"
[ "_$LATEST_STABLE" = "_0.6" ] || die "remote stable is not latest even minor: expected 0.6, got $LATEST_STABLE"
LATEST_NODE="$(nvm_print_implicit_alias remote node)"
[ "_$LATEST_NODE" = "_stable" ] || die "remote node is not stable: expected stable, got $LATEST_NODE"
LATEST_UNSTABLE="$(nvm_print_implicit_alias remote unstable)"
[ "_$LATEST_UNSTABLE" = "_0.9" ] || die "remote unstable is not latest odd minor: expected 0.9, got $LATEST_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

@@ -0,0 +1,28 @@
#!/bin/sh
cleanup () {
alias nvm_has='\nvm_has'
alias npm='\npm'
unset -f nvm_has npm
}
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
nvm_has() { return 1; }
OUTPUT="$(nvm_print_npm_version)"
[ -z "$OUTPUT" ] || die "nvm_print_npm_version did not return empty when nvm_has returns 1, got '$OUTPUT'"
nvm_has() { return 0; }
npm() {
if [ "_$@" = "_--version" ]; then
echo "1.2.3"
else
echo "error"
fi
}
OUTPUT="$(nvm_print_npm_version)"
EXPECTED_OUTPUT=" (npm v1.2.3)"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_print_npm_version did not provided '$EXPECTED_OUTPUT', got '$OUTPUT'"
cleanup

View File

@@ -0,0 +1,78 @@
#!/bin/sh
die () { echo $@ ; cleanup ; exit 1; }
cleanup() {
unset -f nvm_ls_remote nvm_ls_remote_iojs
}
. ../../../nvm.sh
nvm_ls_remote() {
echo "N/A"
}
OUTPUT="$(nvm_remote_version foo)"
EXIT_CODE="$(nvm_remote_version foo >/dev/null 2>&1 ; echo $?)"
[ "_$OUTPUT" = "_N/A" ] || die "nonexistent version did not report N/A"
[ "_$EXIT_CODE" = "_3" ] || die "nonexistent version did not exit with code 3, got $EXIT_CODE"
nvm_ls_remote_iojs() {
echo "N/A"
}
OUTPUT="$(nvm_remote_version iojs-foo)"
EXIT_CODE="$(nvm_remote_version iojs-foo >/dev/null 2>&1 ; echo $?)"
[ "_$OUTPUT" = "_N/A" ] || die "nonexistent version did not report N/A"
[ "_$EXIT_CODE" = "_3" ] || die "nonexistent version did not exit with code 3, got $EXIT_CODE"
nvm_ls_remote() {
if ! nvm_is_iojs_version "$1"; then
echo "test output"
echo "more test output"
echo "pattern received: _$1_"
fi
}
nvm_ls_remote_iojs() {
if [ -z "$1" ] || nvm_is_iojs_version "$1"; then
echo "test iojs output"
echo "more iojs test output"
echo "iojs pattern received: _$1_"
fi
}
OUTPUT="$(nvm_remote_version foo)"
EXIT_CODE="$(nvm_remote_version foo >/dev/null 2>&1 ; echo $?)"
[ "_$OUTPUT" = "_pattern received: _foo_" ] \
|| die "nvm_remote_version foo did not return last line only of nvm_ls_remote foo; got $OUTPUT"
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version foo did not exit with 0, got $EXIT_CODE"
OUTPUT="$(nvm_remote_version iojs-foo)"
EXIT_CODE="$(nvm_remote_version iojs-foo >/dev/null 2>&1 ; echo $?)"
[ "_$OUTPUT" = "_iojs pattern received: _iojs-foo_" ] \
|| die "nvm_remote_version iojs-foo did not return last line only of nvm_ls_remote_iojs foo; got $OUTPUT"
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version iojs-foo did not exit with 0, got $EXIT_CODE"
OUTPUT="$(nvm_remote_version iojs)"
EXIT_CODE="$(nvm_remote_version iojs >/dev/null 2>&1 ; echo $?)"
[ "_$OUTPUT" = "_iojs pattern received: __" ] \
|| die "nvm_remote_version iojs did not return last line only of nvm_ls_remote_iojs; got $OUTPUT"
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version iojs did not exit with 0, got $EXIT_CODE"
OUTPUT="$(nvm_remote_version stable)"
EXIT_CODE="$(nvm_remote_version stable >/dev/null 2>&1 ; echo $?)"
[ "_$OUTPUT" = "_$(nvm_ls_remote stable)" ] \
|| die "nvm_remote_version stable did not return contents of nvm_ls_remote stable; got $OUTPUT"
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version stable did not exit with 0, got $EXIT_CODE"
OUTPUT="$(nvm_remote_version unstable)"
EXIT_CODE="$(nvm_remote_version unstable >/dev/null 2>&1 ; echo $?)"
[ "_$OUTPUT" = "_$(nvm_ls_remote unstable)" ] \
|| die "nvm_remote_version unstable did not return contents of nvm_ls_remote unstable; got $OUTPUT"
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version unstable did not exit with 0, got $EXIT_CODE"
OUTPUT="$(nvm_remote_version node)"
EXIT_CODE="$(nvm_remote_version node >/dev/null 2>&1 ; echo $?)"
[ "_$OUTPUT" = "_$(nvm_ls_remote node)" ] \
|| die "nvm_remote_version node did not return contents of nvm_ls_remote node; got $OUTPUT"
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version node did not exit with 0, got $EXIT_CODE"
cleanup

View File

@@ -0,0 +1,78 @@
#!/bin/sh
die () { echo $@ ; cleanup ; exit 1; }
cleanup() {
unset -f nvm_ls_remote nvm_ls_remote_iojs
}
. ../../../nvm.sh
OUTPUT="$(nvm_remote_versions stable 2>&1)"
EXPECTED_OUTPUT="Implicit aliases are not supported in nvm_remote_versions."
EXIT_CODE="$(nvm_remote_versions stable >/dev/null 2>&1; echo $?)"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "implicit alias 'stable' did not error out with correct message, got $OUTPUT"
[ "_$EXIT_CODE" = "_1" ] || die "implicit alias 'stable' did not exit with code 1, got $EXIT_CODE"
OUTPUT="$(nvm_remote_versions unstable 2>&1)"
EXPECTED_OUTPUT="Implicit aliases are not supported in nvm_remote_versions."
EXIT_CODE="$(nvm_remote_versions unstable >/dev/null 2>&1; echo $?)"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "implicit alias 'unstable' did not error out with correct message, got $OUTPUT"
[ "_$EXIT_CODE" = "_1" ] || die "implicit alias 'unstable' did not exit with code 1, got $EXIT_CODE"
nvm_ls_remote() {
echo "N/A"
}
OUTPUT="$(nvm_remote_versions foo)"
EXIT_CODE="$(nvm_remote_versions foo >/dev/null 2>&1 ; echo $?)"
[ "_$OUTPUT" = "_N/A" ] || die "nonexistent version did not report N/A"
[ "_$EXIT_CODE" = "_3" ] || die "nonexistent version did not exit with code 3, got $EXIT_CODE"
nvm_ls_remote_iojs() {
echo "N/A"
}
OUTPUT="$(nvm_remote_versions iojs-foo)"
EXIT_CODE="$(nvm_remote_versions iojs-foo >/dev/null 2>&1 ; echo $?)"
[ "_$OUTPUT" = "_N/A" ] || die "nonexistent version did not report N/A"
[ "_$EXIT_CODE" = "_3" ] || die "nonexistent version did not exit with code 3, got $EXIT_CODE"
nvm_ls_remote() {
echo "test output"
echo "more test output"
echo "pattern received: _$1_"
}
nvm_ls_remote_iojs() {
echo "test iojs output"
echo "more iojs test output"
echo "iojs pattern received: _$1_"
}
OUTPUT="$(nvm_remote_versions foo)"
EXIT_CODE="$(nvm_remote_versions foo >/dev/null 2>&1 ; echo $?)"
[ "_$OUTPUT" = "_$(nvm_ls_remote foo)
$(nvm_ls_remote_iojs foo)" ] \
|| die "nvm_remote_versions foo did not return contents of nvm_ls_remote foo combined with nvm_ls_remote_iojs foo; got $OUTPUT"
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_versions foo did not exit with 0, got $EXIT_CODE"
OUTPUT="$(nvm_remote_versions node)"
EXIT_CODE="$(nvm_remote_versions node >/dev/null 2>&1 ; echo $?)"
[ "_$OUTPUT" = "_$(nvm_ls_remote)" ] \
|| die "nvm_remote_versions node did not return contents of nvm_ls_remote; got $OUTPUT"
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_versions node did not exit with 0, got $EXIT_CODE"
OUTPUT="$(nvm_remote_versions iojs-foo)"
EXIT_CODE="$(nvm_remote_versions iojs-foo >/dev/null 2>&1 ; echo $?)"
[ "_$OUTPUT" = "_$(nvm_ls_remote iojs-foo)
$(nvm_ls_remote_iojs iojs-foo)" ] \
|| die "nvm_remote_versions iojs-foo did not return contents of nvm_ls_remote iojs-foo combined with nvm_ls_remote_iojs iojs-foo; got $OUTPUT"
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_versions iojs-foo did not exit with 0, got $EXIT_CODE"
OUTPUT="$(nvm_remote_versions iojs)"
EXIT_CODE="$(nvm_remote_versions iojs >/dev/null 2>&1 ; echo $?)"
[ "_$OUTPUT" = "_$(nvm_ls_remote_iojs)" ] \
|| die "nvm_remote_versions iojs did not return contents of nvm_ls_remote_iojs; got $OUTPUT"
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_versions iojs did not exit with 0, got $EXIT_CODE"
cleanup

View File

@@ -0,0 +1,10 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
[ "_$(nvm_strip_iojs_prefix iojs)" = "_" ] || die '"nvm_strip_iojs_prefix iojs" did not return an empty string'
[ "_$(nvm_strip_iojs_prefix iojs-)" = "_" ] || die '"nvm_strip_iojs_prefix iojs-" did not return an empty string'
[ "_$(nvm_strip_iojs_prefix iojs-foo)" = "_foo" ] || die '"nvm_strip_iojs_prefix iojs-foo" did not return "foo"'
[ "_$(nvm_strip_iojs_prefix iojsfoo)" = "_iojsfoo" ] || die '"nvm_strip_iojs_prefix iojsfoo" did not return "iojsfoo"'

View File

@@ -4,7 +4,7 @@ die () { echo $@ ; exit 1; }
. ../../../nvm.sh
TEST_PATH=$NVM_DIR/v0.10.5/bin:/usr/bin:$NVM_DIR/v0.11.5/bin:$NVM_DIR/v0.9.5/bin:/usr/local/bin:$NVM_DIR/v0.2.5/bin
TEST_PATH=$NVM_DIR/v0.10.5/bin:/usr/bin:$NVM_DIR/v0.11.5/bin:$NVM_DIR/v0.9.5/bin:/usr/local/bin:$NVM_DIR/v0.2.5/bin:$NVM_DIR/versions/node/v0.12.0/bin:$NVM_DIR/versions/io.js/v1.0.0/bin
STRIPPED_PATH=`nvm_strip_path "$TEST_PATH" "/bin"`

View File

@@ -0,0 +1,21 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
EXPECTED_MSG="Only implicit aliases 'stable', 'unstable', 'iojs', and 'node' are supported."
[ "_$(nvm_validate_implicit_alias 2>&1)" = "_$EXPECTED_MSG" ] \
|| die "nvm_validate_implicit_alias did not require stable|unstable|iojs|node"
[ "_$(nvm_validate_implicit_alias foo 2>&1)" = "_$EXPECTED_MSG" ] \
|| die "nvm_validate_implicit_alias did not require stable|unstable|iojs|node"
EXIT_CODE="$(nvm_validate_implicit_alias >/dev/null 2>&1 ; echo $?)"
[ "_$EXIT_CODE" = "_1" ] \
|| die "nvm_validate_implicit_alias without stable|unstable|iojs|node had wrong exit code: expected 1, got $EXIT_CODE"
nvm_validate_implicit_alias stable || die "nvm_validate_implicit_alias stable did not exit 0"
nvm_validate_implicit_alias unstable || die "nvm_validate_implicit_alias unstable did not exit 0"
nvm_validate_implicit_alias node || die "nvm_validate_implicit_alias node did not exit 0"
nvm_validate_implicit_alias iojs || die "nvm_validate_implicit_alias iojs did not exit 0"

View File

@@ -0,0 +1,48 @@
#!/bin/sh
die () { echo $@ ; cleanup ; exit 1; }
cleanup () {
unset -f nvm_ls_current nvm_ls
}
. ../../../nvm.sh
nvm_ls_current() {
echo "CURRENT!"
return 7
}
OUTPUT="$(nvm_version current)"
EXPECTED_OUTPUT="CURRENT!"
EXIT_CODE="$(nvm_version current 2>&1 >/dev/null ; echo $?)"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die '"nvm_version current" did not return nvm_ls_current output'
[ "_$EXIT_CODE" = "_7" ] || die '"nvm_version current" did not return nvm_ls_current exit code'
OUTPUT="$(nvm_version)"
EXPECTED_OUTPUT="CURRENT!"
EXIT_CODE="$(nvm_version 2>&1 >/dev/null ; echo $?)"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die '"nvm_version" did not return nvm_ls_current output'
[ "_$EXIT_CODE" = "_7" ] || die '"nvm_version" did not return nvm_ls_current exit code'
nvm_ls() {
echo "line 1"
echo "line 2"
echo "pattern: $1"
}
[ "_$(nvm_version foo)" = "_pattern: foo" ] || die '"nvm_version foo" did not pass the pattern to "nvm_ls", or return the last line'
[ "_$(nvm_version node)" = "_pattern: stable" ] || die '"nvm_version node" did not pass "stable" to "nvm_ls"'
[ "_$(nvm_version node-)" = "_pattern: stable" ] || die '"nvm_version node-" did not pass "stable" to "nvm_ls"'
nvm_ls() { echo "N/A"; }
OUTPUT="$(nvm_version foo)"
EXPECTED_OUTPUT="N/A"
EXIT_CODE="$(nvm_version foo 2>&1 >/dev/null ; echo $?)"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die '"nvm_version" did not return N/A when nvm_ls returns N/A'
[ "_$EXIT_CODE" = "_3" ] || die '"nvm_version" returning N/A did not exit code with code 3'
nvm_ls() { echo; }
OUTPUT="$(nvm_version foo)"
EXPECTED_OUTPUT="N/A"
EXIT_CODE="$(nvm_version foo 2>&1 >/dev/null ; echo $?)"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die '"nvm_version" did not return N/A when nvm_ls returns nothing'
[ "_$EXIT_CODE" = "_3" ] || die '"nvm_version" returning N/A did not exit code with code 3'

View File

@@ -4,7 +4,8 @@ die () { echo $@ ; exit 1; }
. ../../../nvm.sh
[ "$(nvm_version_dir)" = "$NVM_DIR/versions" ] || die '"nvm_version_dir" did not return new dir path'
[ "$(nvm_version_dir)" = "$NVM_DIR/versions/node" ] || die '"nvm_version_dir" did not return new dir path'
[ "$(nvm_version_dir iojs)" = "$NVM_DIR/versions/io.js" ] || die '"nvm_version_dir iojs" did not return iojs dir path'
[ "$(nvm_version_dir new)" = "$(nvm_version_dir)" ] || die '"nvm_version_dir new" did not return new dir path'
[ "$(nvm_version_dir old)" = "$NVM_DIR" ] || die '"nvm_version_dir old" did not return old dir path'
[ "$(nvm_version_dir foo 2>&1)" = "unknown version dir" ] || die '"nvm_version_dir foo" did not error out'

View File

@@ -7,5 +7,6 @@ die () { echo $@ ; exit 1; }
[ "$(nvm_version_path foo)" = "$NVM_DIR/foo" ] || die '"nvm_version_path foo" did not return correct location'
[ "$(nvm_version_path 2>&1)" = "version is required" ] || die '"nvm_version_path" did not error out'
[ "$(nvm_version_path v0.11.0)" = "$NVM_DIR/v0.11.0" ] || die 'old version has the wrong path'
[ "$(nvm_version_path v0.12.0)" = "$NVM_DIR/versions/v0.12.0" ] || die 'new version has the wrong path'
[ "$(nvm_version_path v0.12.0)" = "$NVM_DIR/versions/node/v0.12.0" ] || die 'new version has the wrong path'
[ "$(nvm_version_path iojs-v0.12.0)" = "$NVM_DIR/versions/io.js/v0.12.0" ] || die 'iojs version has the wrong path'

View File

@@ -0,0 +1,54 @@
#!/bin/sh
cleanup () {
rm -rf "$npm_config_prefix/lib" >/dev/null 2>&1
unset npm_config_prefix
rm -f npm
PATH="$ORIGINAL_PATH"
unset -f setup cleanup die
unset message ORIGINAL_PATH
}
die () { echo $@ ; cleanup ; exit 1; }
NVM_ENV=testing . ../../install.sh
setup () {
ORIGINAL_PATH="$PATH"
npm_config_prefix="$(pwd)"
export npm_config_prefix
mkdir -p "$npm_config_prefix/lib"
}
setup
npm install -g nop >/dev/null || die 'nvm_check_global_modules cannot be tested because `npm` cannot install the `nop` package'
message=$(nvm_check_global_modules)
[ ! -z "$message" ] || die "nvm_check_global_modules should have printed a notice when npm had global modules installed"
npm uninstall -g nop >/dev/null
message=$(nvm_check_global_modules)
[ -z "$message" ] || die "nvm_check_global_modules should not have printed a notice when npm had no global modules installed"
# Faking an installation of npm
mkdir -p "$npm_config_prefix/lib/node_modules/npm"
cat <<'JSON' >"$npm_config_prefix/lib/node_modules/npm/package.json"
{ "name": "npm", "version": "0.0.1fake" }
JSON
message=$(nvm_check_global_modules)
[ -z "$message" ] || die "nvm_check_global_modules should have not printed a notice when npm had only itself installed as a global module"
# Faking the absence of npm
PATH=".:$PATH"
touch npm
chmod +x npm
message=$(nvm_check_global_modules)
[ -z "$message" ] || die "nvm_check_global_modules should have not printed a notice when npm was unavailable"
cleanup

View File

@@ -0,0 +1,101 @@
#!/bin/sh
cleanup () {
unset -f setup cleanup die
unset _PROFILE
rm -f .bashrc .bash_profile .zshrc .profile test_profile > /dev/null 2>&1
}
die () { echo $@ ; cleanup ; exit 1; }
NVM_ENV=testing . ../../install.sh
setup () {
touch .bashrc
touch .bash_profile
touch .zshrc
touch .profile
touch test_profile
}
#Let's hack $HOME
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" ] || 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" ] || 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 .profile if file exists
_PROFILE=$(nvm_detect_profile)
[ "_$_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" ] || 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" ] || echo "_\$_PROFILE: _$_PROFILE\n" \
echo "_\$PROFILE: _$PROFILE\n" \
die "nvm_detect_profile should have selected .zshrc"
rm .zshrc
# It should be empty if none is found
_PROFILE=$(nvm_detect_profile)
[ -z "$_PROFILE" ] || echo "_\$_PROFILE: _$_PROFILE\n" \
echo "_\$PROFILE: _$PROFILE\n" \
die "nvm_detect_profile should have echo'ed an empty value"
cleanup

View File

@@ -0,0 +1,9 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
NVM_ENV=testing . ../../install.sh
#nvm_do_install is available
type nvm_do_install > /dev/null 2>&1 || die 'nvm_do_install is not available'

30
test/install_script/nvm_reset Executable file
View File

@@ -0,0 +1,30 @@
#!/bin/sh
cleanup () {
unset -f safe_type die cleanup
}
die () { echo $@ ; cleanup ; exit 1; }
NVM_ENV=testing . ../../install.sh
safe_type() {
type "$1" > /dev/null 2>&1
}
# Check nvm_reset exists
safe_type nvm_reset || die 'nvm_reset is not available'
# Apply nvm_reset
nvm_reset || die 'nvm_reset failed'
# The names should be unset
! safe_type nvm_do_install || die 'nvm_do_install is still available'
! safe_type nvm_has || die 'nvm_has is still available'
! safe_type nvm_download || die 'nvm_download is still available'
! safe_type install_nvm_as_script || die 'install_nvm_as_script is still available'
! safe_type install_nvm_from_git || die 'install_nvm_from_git is still available'
! safe_type nvm_reset || die 'nvm_reset is still available'
! safe_type nvm_detect_profile || die 'nvm_detect_profile is still available'
cleanup

40
test/install_script/nvm_source Executable file
View File

@@ -0,0 +1,40 @@
#!/bin/sh
cleanup () {
unset -f die cleanup
unset NVM_SOURCE out
}
die () { echo $@ ; cleanup ; exit 1; }
NVM_ENV=testing . ../../install.sh
# nvm_source with no parameter returns the git endpoint
echo $(nvm_source) | grep "nvm.git$" > /dev/null || die "nvm_source without arguments should return the location of the git repo"
# nvm_source with git parameter returns the location of the nvm repo
echo $(nvm_source "git") | grep "nvm.git$" > /dev/null || die "nvm_source without arguments should return the location of the git repo"
# nvm_source with script parameter returns the location of nvm.sh
echo $(nvm_source "script") | grep "nvm.sh$" > /dev/null || die "nvm_source \"script\" should return the location of nvm.sh"
# nvm_source with script-nvm-exec parameter returns the location of nvm-exec
echo $(nvm_source "script-nvm-exec") | grep "nvm-exec$" > /dev/null || die "nvm_source \"script-nvm-exec\" should return the location of nvm.sh"
# nvm_source with any other parameter errors out and exits
nvm_source "anything" 2> /dev/null && die "nvm_source with invalid parameter should exit"
out=$(nvm_source "anything" 2>&1 >/dev/null) || : #Saving the process here
[ -z "$out" ] && die "nvm_source with invalid parameter should error out"
#nvm_source should always return NVM_SOURCE no matter the parameters
NVM_SOURCE="my_location"
out=$(nvm_source)
[ "_$out" = "_my_location" ] || die "nvm_source without arguments should have returned \$NVM_SOURCE. Got \"$out\""
out=$(nvm_source "git")
[ "_$out" = "_my_location" ] || die "nvm_source git should have returned \$NVM_SOURCE. Got \"$out\""
out=$(nvm_source "script")
[ "_$out" = "_my_location" ] || die "nvm_source script should have returned \$NVM_SOURCE. Got \"$out\""
out=$(nvm_source "anything")
[ "_$out" = "_my_location" ] || die "nvm_source script should have returned \$NVM_SOURCE. Got \"$out\""
cleanup

View File

@@ -1,17 +0,0 @@
#!/bin/sh
set -e
. ../../nvm.sh
NVM_TEST_VERSION=v0.10.7
# Remove the stuff we're clobbering.
[ -e ../../$NVM_TEST_VERSION ] && rm -R ../../$NVM_TEST_VERSION
# Install from binary
nvm install $NVM_TEST_VERSION
# Check
[ -d ../../$NVM_TEST_VERSION ]
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION

View File

@@ -1,17 +0,0 @@
#!/bin/sh
set -e
. ../../nvm.sh
NVM_TEST_VERSION=v0.10.7
# Remove the stuff we're clobbering.
[ -e ../../$NVM_TEST_VERSION ] && rm -R ../../$NVM_TEST_VERSION
# Install from source
nvm install -s $NVM_TEST_VERSION
# Check
[ -d ../../$NVM_TEST_VERSION ]
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION

View File

@@ -1,24 +0,0 @@
#!/bin/sh
set -e
. ../../nvm.sh
# Remove the stuff we're clobbering.
[ -e ../../v0.9.7 ] && rm -R ../../v0.9.7
[ -e ../../v0.9.12 ] && rm -R ../../v0.9.12
# Install from binary
nvm install 0.9.7
nvm i 0.9.12
# Check
[ -d ../../v0.9.7 ]
[ -d ../../v0.9.12 ]
# Use the first one
nvm use 0.9.7
# Use the latest one
nvm use 0.9
node --version | grep v0.9.12

View File

@@ -1,20 +0,0 @@
#!/bin/sh
set -e
. ../../nvm.sh
NVM_TEST_VERSION=v0.10.7
# Remove the stuff we're clobbering.
[ -e ../../$NVM_TEST_VERSION ] && rm -R ../../$NVM_TEST_VERSION
# Install from binary
echo "$NVM_TEST_VERSION" > .nvmrc
nvm install
# Check
[ -d ../../$NVM_TEST_VERSION ]
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION

View File

@@ -1,20 +0,0 @@
#!/bin/sh
set -e
. ../../nvm.sh
NVM_TEST_VERSION=v0.10.7
# Remove the stuff we're clobbering.
[ -e ../../$NVM_TEST_VERSION ] && rm -R ../../$NVM_TEST_VERSION
# Install from binary
echo "$NVM_TEST_VERSION" > .nvmrc
nvm install -s
# Check
[ -d ../../$NVM_TEST_VERSION ]
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION

View File

@@ -1,34 +0,0 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../nvm.sh
# Remove the stuff we're clobbering.
[ -e ../../v0.9.7 ] && rm -R ../../v0.9.7
[ -e ../../v0.9.12 ] && rm -R ../../v0.9.12
# Install from binary
nvm install 0.9.7
# Check
[ -d ../../v0.9.7 ] || die "nvm install 0.9.7 didn't install"
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"
nvm ls 0.9 | grep v0.9.7 > /dev/null || die "nvm ls 0.9 didn't show v0.9.7"
nvm install 0.9.12 --copy-packages-from=0.9 || die "nvm install 0.9.12 --copy-packages-from=0.9 failed"
[ -d ../../v0.9.12 ] || die "nvm install 0.9.12 didn't install"
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"

View File

@@ -0,0 +1,26 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
[ "$(nvm install invalid.invalid 2>&1)" = "Version 'invalid.invalid' not found - try \`nvm ls-remote\` to browse available versions." ] || die "nvm installing an invalid version did not print a nice error message"
# Remove the stuff we're clobbering.
[ -e ../../../versions/io.js/v1.0.0 ] && rm -R ../../../versions/io.js/v1.0.0
[ -e ../../../versions/io.js/v1.0.1 ] && rm -R ../../../versions/io.js/v1.0.1
# Install from binary
nvm install iojs-v1.0.0
nvm install iojs-v1.0.1
nvm use iojs-v1.0.0
node --version | grep v1.0.0 || die "precondition failed: iojs node doesn't start at v1.0.0"
iojs --version | grep v1.0.0 || die "precondition failed: iojs binary doesn't start at v1.0.0"
nvm install iojs-v1.0.1
node --version | grep v1.0.1 || die "nvm install on already installed version doesn't use it (node binary)"
iojs --version | grep v1.0.1 || die "nvm install on already installed version doesn't use it (iojs binary)"

View File

@@ -0,0 +1,19 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
NVM_TEST_VERSION="v1.0.0"
NVM_PREFIXED_TEST_VERSION="iojs-$NVM_TEST_VERSION"
# Remove the stuff we're clobbering.
[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION
# Install from binary
nvm install $NVM_PREFIXED_TEST_VERSION || die "install $NVM_PREFIXED_TEST_VERSION failed"
# Check
[ -d ../../../versions/io.js/$NVM_TEST_VERSION ]
nvm run $NVM_PREFIXED_TEST_VERSION --version | grep $NVM_TEST_VERSION || die "'nvm run $NVM_PREFIXED_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed"

View File

@@ -0,0 +1,26 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
# Remove the stuff we're clobbering.
[ -e ../../../versions/io.js/v1.0.0 ] && rm -R ../../../versions/io.js/v1.0.0
[ -e ../../../versions/io.js/v1.0.1 ] && rm -R ../../../versions/io.js/v1.0.1
# Install from binary
nvm install iojs-v1.0.0 || die "'nvm install iojs-v1.0.0' failed"
nvm i iojs-v1.0.1 || die "'nvm i iojs-v1.0.1' failed"
# Check
[ -d ../../../versions/io.js/v1.0.0 ] || die "iojs v1.0.0 didn't exist"
[ -d ../../../versions/io.js/v1.0.1 ] || die "iojs v1.0.1 didn't exist"
# Use the first one
nvm use iojs-1.0.0 || die "'nvm use iojs-1.0.0' failed"
# Use the latest one
nvm use iojs-1 || die "'nvm use iojs-1' failed"
[ "_$(node --version)" = "_v1.0.1" ] || die "'node --version' was not v1.0.1, got: $(node --version)"
[ "_$(iojs --version)" = "_v1.0.1" ] || die "'iojs --version' was not v1.0.1, got: $(iojs --version)"

View File

@@ -0,0 +1,24 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
NVM_TEST_VERSION=v1.0.0
NVM_PREFIXED_TEST_VERSION="iojs-$NVM_TEST_VERSION"
VERSION_PATH="../../../versions/io.js/$NVM_TEST_VERSION"
# Remove the stuff we're clobbering.
[ -e $VERSION_PATH ] && rm -R $VERSION_PATH
# Install from binary
echo "$NVM_PREFIXED_TEST_VERSION" > .nvmrc
nvm install || die "'nvm install' failed"
# Check
[ -d $VERSION_PATH ] || die "./$VERSION_PATH did not exist"
nvm run $NVM_PREFIXED_TEST_VERSION --version | grep $NVM_TEST_VERSION \
|| "'nvm run $NVM_PREFIXED_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed"

View File

@@ -0,0 +1,32 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
# Remove the stuff we're clobbering.
[ -e ../../../versions/io.js/v1.0.0 ] && rm -R ../../../versions/io.js/v1.0.0
[ -e ../../../versions/io.js/v1.0.1 ] && rm -R ../../../versions/io.js/v1.0.1
# Install from binary
nvm install iojs-v1.0.0
# Check
[ -d ../../../versions/io.js/v1.0.0 ] || die "nvm install iojs-v1.0.0 didn't install"
node --version | grep v1.0.0 > /dev/null || die "nvm install didn't use iojs-v1.0.0"
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"
nvm install iojs-v1.0.1 --reinstall-packages-from=iojs-1.0.0 || die "nvm install iojs-v1.0.1 --reinstall-packages-from=iojs-1.0.0 failed"
[ -d ../../../versions/io.js/v1.0.1 ] || die "nvm install iojs-v1.0.1 didn't 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 object-is > /dev/null || die "object-is isn't installed"

View File

@@ -0,0 +1,20 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
NVM_VERSION="v1"
NVM_PREFIXED_TEST_VERSION="$(nvm ls-remote "$NVM_VERSION" | tail -n1 | sed 's/^[ ]*//;s/[ ]*$//')"
NVM_TEST_VERSION="$(nvm_strip_iojs_prefix "$NVM_PREFIXED_TEST_VERSION")"
# Remove the stuff we're clobbering.
[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION
# Install from binary
nvm install "$NVM_VERSION" || die "nvm install $NVM_VERSION failed"
# Check
[ -d ../../../versions/io.js/$NVM_TEST_VERSION ]
nvm run $NVM_PREFIXED_TEST_VERSION --version | grep $NVM_TEST_VERSION || die "'nvm run $NVM_PREFIXED_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed"

View File

@@ -0,0 +1,14 @@
#!/bin/sh
. ../../../nvm.sh
nvm deactivate
nvm uninstall iojs-v1.0.0
if [ -f ".nvmrc" ]; then
rm .nvmrc
fi
if [ -f ".nvmrc.bak" ]; then
mv .nvmrc.bak .nvmrc
fi

View File

@@ -2,13 +2,13 @@
die () { echo $@ ; exit 1; }
. ../../nvm.sh
. ../../../nvm.sh
[ "$(nvm install invalid.invalid 2>&1)" = "Version 'invalid.invalid' not found - try \`nvm ls-remote\` to browse available versions." ] || die "nvm installing an invalid version did not print a nice error message"
# Remove the stuff we're clobbering.
[ -e ../../v0.9.7 ] && rm -R ../../v0.9.7
[ -e ../../v0.9.12 ] && rm -R ../../v0.9.12
[ -e ../../../v0.9.7 ] && rm -R ../../../v0.9.7
[ -e ../../../v0.9.12 ] && rm -R ../../../v0.9.12
# Install from binary
nvm install 0.9.7

Some files were not shown because too many files have changed in this diff Show More