Compare commits

..

188 Commits

Author SHA1 Message Date
Jordan Harband
db8acf11fd v0.7.0 2014-05-08 10:30:52 -07:00
Jordan Harband
a6be718387 Fixing --version output format. 2014-05-08 10:30:34 -07:00
Jordan Harband
e2c4c88136 Updating example node versions. 2014-05-08 10:30:18 -07:00
Jordan Harband
4cd0b078d0 Merge pull request #415 from koenpunt/fix-path-concat
utility method for append path, fixes #414
2014-05-08 10:27:17 -07:00
Koen Punt
f6ba08253b utility method for append path, fixes #414 2014-05-08 10:20:11 +02:00
Jordan Harband
0ecb2879b9 Merge pull request #412 from koenpunt/fix-sed
Use sed -e instead of -E
2014-05-07 10:32:00 -07:00
Koen Punt
e3b84499c2 use regex triplet, add unit test 2014-05-07 10:58:21 +02:00
Koen Punt
b313f62749 Use sed -e instead of -E 2014-05-07 10:58:18 +02:00
Jordan Harband
7f3a794d89 Merge pull request #409 from koenpunt/sed-path-replacement
Use sed for *PATH stripping
2014-05-06 01:37:49 -07:00
Jordan Harband
ba1be9b4ea Making nvm install use the version, even if it's already installed. Fixes #410 2014-05-05 23:32:39 -07:00
Koen Punt
652a9ef9b5 always apply path stripping 2014-05-06 00:00:25 +02:00
Koen Punt
0d81a219ae add quotes 2014-05-05 22:05:02 +02:00
Koen Punt
d6e457354f use nvm_strip_path utility method for path stripping 2014-05-05 22:03:11 +02:00
Koen Punt
6668dc5c47 remove parentheses 2014-05-05 21:50:59 +02:00
Koen Punt
3d9c1d7852 use sed for *PATH stripping 2014-05-05 21:43:22 +02:00
Jordan Harband
29f582611b v0.6.1 2014-05-04 12:40:02 -07:00
Jordan Harband
673cda56c4 Adding a test for nvm install invalid behavior, and correcting the message.
From f00d688c87 (commitcomment-6205164)
2014-05-04 12:03:26 -07:00
Jordan Harband
e562a5645b v0.6.0 2014-05-04 02:20:31 -07:00
Jordan Harband
c0c5e8d7ef Editing README to note improved .nvmrc behavior. 2014-05-04 02:20:24 -07:00
Jordan Harband
f00d688c87 Nicer failure message when trying to install an invalid version. Fixes #285. 2014-05-04 00:59:08 -07:00
Jordan Harband
5aa78f21cf Merge branch 'nvmrc' - Fixes #404 2014-05-04 00:47:16 -07:00
Jordan Harband
4a7275a0c6 Ensuring paths are in quotes, to preserve spaces. 2014-05-04 00:39:46 -07:00
Jordan Harband
c77be55cdc Updating "nvm run" tests. 2014-05-04 00:39:32 -07:00
Jordan Harband
e195fccdb7 Escaping backticks 2014-05-03 23:29:21 -07:00
Jordan Harband
87516039a8 Using portable conditional syntax. 2014-05-02 23:28:42 -07:00
Koen Punt
80e349edb1 locate .nvmrc without find
instead of using find and actually cd'ing into directories
we're now using simple string replacement on the `pwd`
2014-05-02 23:02:34 -07:00
Jordan Harband
038c1f3d0f Find .nvmrc files upwards. 2014-05-02 23:02:34 -07:00
Jordan Harband
66455f7c77 Refactor so "finding .nvmrc" can be done in a bash function. 2014-05-02 23:02:34 -07:00
Jordan Harband
a69eae10e3 Merge pull request #405 from reqshark/master
github raw served from new subdomain
2014-04-26 10:03:41 -07:00
Bent Cardan
13b87449e8 github raw served from new subdomain 2014-04-26 03:48:06 -04:00
Jordan Harband
222250f2d1 v0.5.1 2014-04-25 10:47:59 -07:00
Jordan Harband
77f4490391 Using markdown footnotes. 2014-04-25 10:47:07 -07:00
Jordan Harband
0871131dfd Make sure nvm-exec can use .nvmrc logic. Fixes #402, obviates #403. 2014-04-25 10:38:21 -07:00
Jordan Harband
e6bd207624 When auto-printing "help" on a command other than "help", return a nonzero exit code. 2014-04-25 10:35:52 -07:00
Jordan Harband
bad79e6d77 v0.5.0 2014-04-20 00:36:12 -07:00
Jordan Harband
d07fa2db10 Merge pull request #399 from creationix/run_use_nvmrc
Make sure `nvm run` works without a version argument when .nvmrc specifies a version
2014-04-20 00:35:59 -07:00
Jordan Harband
20953ab04c Make sure nvm run works without a version argument when .nvmrc specifies a version. 2014-04-20 00:28:07 -07:00
Jordan Harband
4cf940153c Use node 0.9 for these testsso that people aren't likely to have it installed 2014-04-19 23:41:36 -07:00
Jordan Harband
47bbf93f50 Travis CI defaults to ruby; c will be faster 2014-04-19 22:59:30 -07:00
Jordan Harband
7976a1343f Merge pull request #398 from creationix/install_use_nvmrc
`nvm install` and `nvm run` use .nvmrc when version not provided
2014-04-19 22:36:33 -07:00
Jordan Harband
bf8abf1052 Make sure nvm install works without a version argument when .nvmrc specifies a version. 2014-04-19 17:07:00 -07:00
Jordan Harband
eb6031cb58 Clean up after existing nvm install tests. 2014-04-19 17:00:06 -07:00
Jordan Harband
55a6f1f06e Organizing nvm install tests better. 2014-04-19 16:48:43 -07:00
Jordan Harband
c188c1b11a Correcting help text for nvm use 2014-04-19 16:46:22 -07:00
Jordan Harband
b15ea07067 Don't clobber the latest version of 0.10 for tests. 2014-04-19 16:46:17 -07:00
Jordan Harband
752c0e4ef1 Removing trailing whitespace. 2014-04-19 14:34:47 -07:00
Jordan Harband
49364532b3 Merge pull request #391 from koenpunt/patch-1
Link to latest version of install script (0.4.0)
2014-03-27 10:19:44 -07:00
Koen Punt
9157cb4cfe Link to latest version of install script (0.4.0) 2014-03-27 10:19:00 +01:00
Jordan Harband
6dde4aac38 v0.4.0 2014-03-26 21:31:48 -07:00
Jordan Harband
96635cd2bd Merge pull request #371 from koenpunt/single-installer
Merged installer and gitless installer into one
2014-03-26 21:30:00 -07:00
Koen Punt
5342b6a04c Emulate curl with wget 2014-03-26 11:14:09 +01:00
Koen Punt
2d0c025c49 Prevent fallback 2014-03-26 11:14:08 +01:00
Koen Punt
6ed93f4c01 Force install method by setting METHOD=git/script 2014-03-26 11:14:08 +01:00
Koen Punt
3c2719a85e fix 2014-03-26 11:14:08 +01:00
Koen Punt
c47f03f996 Display error when unable to update 2014-03-26 11:11:26 +01:00
Koen Punt
300022642a git, curl and wget now all in one installer 2014-03-25 20:53:05 +01:00
Koen Punt
bce3abaa4b use comparison opts 2014-03-25 20:52:30 +01:00
Koen Punt
9f6280265a updated README 2014-03-25 20:52:30 +01:00
Koen Punt
7211c9ee29 updated output without special characters (tab; \t)
Omit duplicate 'finish line'
normalized indentation
2014-03-25 20:51:39 +01:00
Koen Punt
246caa8581 Updated source string, use hard path as NVM is not always installed in $HOME/.nvm 2014-03-25 20:51:39 +01:00
Koen Punt
1fac49f887 replaced undocumented option for specifying the profile as first argument to specifying it as a environment variable (eg: PROFILE=~/.myprofile ./install-gitless.sh)
also; fixed indentation and added .zshrc as possible profile
2014-03-25 20:51:39 +01:00
Koen Punt
d2422a623a made NVM_DIR and NVM_SOURCE configurable using environment variables 2014-03-25 20:51:39 +01:00
Koen Punt
fcc00b22b7 don't make use of pushd and popd as they are not universal 2014-03-25 20:51:39 +01:00
Koen Punt
0787a55999 replaced fatalExit function for 'inline' exit
exit on errors (set -e)
simplified if for NVM_DIR and NVM_SOURCE, corrected indentation
2014-03-25 20:51:39 +01:00
Jordan Harband
7c45d62b37 Merge pull request #388 from koenpunt/small-fixes
Use NVM_ prefix for non local variables
2014-03-23 11:56:09 -07:00
Koen Punt
ec7909dcd3 Use NVM_ prefix for variables 2014-03-23 16:42:38 +01:00
Jordan Harband
cf5f195d75 Merge pull request #387 from koenpunt/patch-1
Add travis badge to README
2014-03-22 14:00:46 -07:00
Koen Punt
9f0520cdd0 Add travis badge to README 2014-03-22 21:19:43 +01:00
Jordan Harband
d950c1a0ea Adding a trailing newline 2014-03-22 13:10:18 -07:00
Jordan Harband
6123fbcd31 Merge pull request #386 from koenpunt/multi-shell-test
Add Makefile for multishell testing
2014-03-22 13:08:50 -07:00
Koen Punt
def7ec5364 install shells before running tests 2014-03-22 18:51:39 +01:00
Koen Punt
52a384a0cc Add Makefile for multishell testing
updated nvm current test for zsh
2014-03-22 18:47:15 +01:00
Jordan Harband
ba1e2f1cdf Merge pull request #382 from koenpunt/version-normalizing
Fix nvm ls for v* numbers
2014-03-21 09:30:19 -07:00
Jordan Harband
625e54880f Merge pull request #374 from koenpunt/fix-tests
Fix NVM_DIR discovery
2014-03-21 09:27:13 -07:00
Jordan Harband
cebda7d35a When curl is not present, immediately bail out of nvm install with a nonzero exit code. Fixes #385. 2014-03-21 09:23:30 -07:00
Koen Punt
4a9a15c404 Fix NVM_DIR discovery 2014-03-21 10:03:16 +01:00
Jordan Harband
31c5406780 Adding an nvm --version command 2014-03-20 23:21:01 -07:00
Koen Punt
a34c080d77 Fix nvm ls for v* numbers
Previously calling nvm ls with v* number (nvm ls v0.2)
would not return any results.

So now the v is prepended if its not already there
2014-03-18 10:53:57 +01:00
Koen Punt
0b97ee1d2a Failing test for when using nvm ls with v* version 2014-03-18 10:49:44 +01:00
Jordan Harband
1ded21c10d Merge pull request #383 from koenpunt/nvm-prefixed
define all functions with nvm_ prefix
2014-03-17 18:07:00 -07:00
Koen Punt
e30424d22f define all functions with nvm_ prefix 2014-03-18 01:41:02 +01:00
Jordan Harband
78e7aa6b67 Merge pull request #380 from koenpunt/fix-current-test
Double == causes error on travis (dash shell)
2014-03-17 12:05:26 -07:00
Koen Punt
ae4c841742 Double == causes error on travis (dash shell) 2014-03-17 19:44:40 +01:00
Jordan Harband
4f9324c439 Merge pull request #377 from koenpunt/remove-obscure-echo-test
Replaced echo for printf when using formatted strings
2014-03-17 10:02:54 -07:00
Jordan Harband
020f61500f Merge pull request #378 from koenpunt/ci
Added travis config, fixed tests for use on travis
2014-03-17 09:59:42 -07:00
Koen Punt
38a0c997e2 Added travis config, fixed tests for use on travis 2014-03-17 14:33:25 +01:00
Koen Punt
70f1734c12 updated tests for altered output 2014-03-17 13:24:24 +01:00
Koen Punt
1d40a5bc8b Replaced echo for printf when using formatted strings
Updated version list, now also compatible with zsh
2014-03-17 13:19:39 +01:00
Jordan Harband
db4c582d79 Merge pull request #366 from messju/nvm_version_fix
fixed nvm_version result when multiple versions match the given pattern
2014-03-15 13:17:36 -07:00
messju mohr
e46ee7b30b added test for using the latest of two versions 2014-03-15 20:42:38 +01:00
messju mohr
f82f38be90 fixed nvm_version result when multiple versions match the given pattern 2014-03-15 20:42:38 +01:00
Jordan Harband
3a21485050 Files should end in trailing newlines 2014-03-15 11:41:50 -07:00
Jordan Harband
e6887d500f Merge pull request #319 from koenpunt/nvm-exec
nvm exec wrapper to execute commands with a specific node version
2014-03-15 11:40:02 -07:00
Jordan Harband
472d23b990 Merge pull request #372 from koenpunt/patch-1
Use has util method and use comparison opts
2014-03-15 10:48:41 -07:00
Koen Punt
1a19de9d20 Use has util method and use comparison opts 2014-03-15 15:59:46 +01:00
Koen Punt
f3d1770e3e nvm exec wrapper to execute commands with a specific node version 2014-03-15 15:58:32 +01:00
Jordan Harband
ba2a850253 Adding a CONTRIBUTING.md file 2014-03-14 23:21:31 -07:00
Jordan Harband
618a372f38 Unset the executable bit on nvm.sh, since it's meant to be sourced 2014-03-14 22:10:52 -07:00
Jordan Harband
a09a028c38 Merge pull request #270 from hachre/patch-1
Switch from /bin/sh to /bin/bash
2014-03-14 22:10:07 -07:00
Jordan Harband
d78905988e Merge pull request #310 from danieltdt/grep-options
Overwritting GREP_OPTIONS on local script
2014-03-14 13:10:56 -07:00
Daniel Teixeira
8cceae3cc1 Overwritting GREP_OPTIONS on local script
(recommiting to automerge into current master)
2014-03-14 14:58:51 -03:00
Jordan Harband
192e381971 Merge pull request #370 from jpadilla/patch-1
Detect if curl or wget is installed to download NVM_SOURCE
2014-03-13 14:26:44 -07:00
José Padilla
966ff0e1b0 Fix for running with bash, sh, and zsh 2014-03-13 10:31:34 -04:00
José Padilla
b90a0a811e Use 2-space indentation for consistency 2014-03-12 14:33:00 -04:00
José Padilla
25ca41c9dc Detect if curl or wget is installed 2014-03-12 09:07:48 -04:00
Jordan Harband
0d44ed1126 Merge pull request #364 from frasertweedale/fix/portability
Fix/portability
2014-03-04 17:31:17 -08:00
Jordan Harband
dc53a37d4f Merge pull request #277 from frasertweedale/fix/freebsd-sha1
support FreeBSD's sha1(1) for integrity checks
2014-02-27 01:25:23 -08:00
Fraser Tweedale
332ae1afcb use a more portable release in install tests
The tests for nvm install currently install v0.8.6, which doesn't
build on FreeBSD due to Linuxisms.  Switch to a more recent version
that does work.
2014-02-22 12:20:15 +10:00
Fraser Tweedale
9108a7f7fa remove duplicate install test
`test/slow/install` is identical to `test/slow/install from source`
except in the version installed.  Remove it.
2014-02-22 12:20:15 +10:00
Fraser Tweedale
3b21b76106 fix install from source on FreeBSD 10
Compile with CXX=c++ on FreeBSD, as FreeBSD >= 10.0 no longer has
GCC in the base system (c++ is hardlinked to clang++ on FreeBSD 10.0
and g++ on FreeBSD < 10).
2014-02-22 11:58:39 +10:00
Fraser Tweedale
dcba513108 address remaining comments from #363 2014-02-22 11:25:45 +10:00
Fraser Tweedale
e6a5374bfb colorize output only if echo supports it 2014-02-22 00:06:53 +10:00
Fraser Tweedale
8cba9c5781 avoid nullglob in alias command 2014-02-22 00:00:10 +10:00
Fraser Tweedale
1d6145de5a fix explicit version matching on FreeBSD
FreeBSD's regular expression library does not like the pattern used
for matching explicit version strings in `nvm_ls`.  Change the
pattern to something more specific that works on FreeBSD.
2014-02-21 23:25:45 +10:00
Fraser Tweedale
ca0c8a7f1d handle echo implementations that do not support -e 2014-02-21 22:10:17 +10:00
Fraser Tweedale
21771e7369 fix logic error in nvm deactivate test 2014-02-21 21:06:53 +10:00
Fraser Tweedale
a3331ffdb0 fix errors due to use of unportable == operator
The `==` operator is not defined by POSIX and many test(1) (also
spelled `[`) implementations do not support it.  Replace uses of
`==` with the POSIX-conformant `=` equality operator.
2014-02-21 21:05:40 +10:00
Fraser Tweedale
4a5f5203d0 fix errors and portability issues in expr commands
Add double-quotes around all expr(1) left-hand-sides where the
argument is just a variable, to prevent syntax errors when the
variable is empty.

Also avoid the `expr match ...` variant as this is not defined in
POSIX and causes errors in some implementations, including
FreeBSD's.
2014-02-21 20:52:50 +10:00
Fraser Tweedale
ee6d4ab074 fix ls command in dash
The `colorize_version` command fails in dash (default /bin/sh on
Ubuntu) with an error like:

  local: v0.2.3: bad variable name

Instead of using a local variable, interpolate the function argument
directly to avoid the error.
2014-02-21 20:24:27 +10:00
Fraser Tweedale
8925419e90 tests: avoid reliance on nullglob
Some shells do not have a nullglob feature, including dash (default
/bin/sh on Ubuntu) and the Almquist shell (default /bin/sh on
FreeBSD).  An mv(1) command in setup_dir is failing due to a glob
not matching anything, so use a more widely supported construction.
2014-02-21 19:21:03 +10:00
Dr. Kibitz
0f709eafa0 Missed tests 2014-02-18 22:07:25 -08:00
Dr. Kibitz
a9be598241 Remove some new bashisms 2014-02-18 21:57:59 -08:00
Dr. Kibitz
9a0c269713 Redo https://github.com/creationix/nvm/pull/345 2014-02-18 21:51:39 -08:00
Fraser Tweedale
0c8410fcc3 support FreeBSD's sha1(1) for integrity checks
In the absense of shasum(1) (which on FreeBSD is provided by Perl,
from ports) nvm falls back to sha1sum(1) which does not exist on
FreeBSD.  But FreeBSD does have sha1(1) so look for sha1(1) and use
it if present.

As part of this change, refactor the execution of the checksum
program down into nvm_checksum and also clean up some special-casing
of empty dist checksums, which is already handled by nvm_checksum.
2014-02-18 22:22:46 +10:00
Jordan Harband
12d7b6fa0c Merge pull request #361 from drkibitz/local-vars
Declare more variables as local
2014-02-16 11:20:21 -08:00
Jordan Harband
274652e10e Fix nvm ls-remote and display uninstalled versions again. Fixes #359, closes #360 2014-02-16 09:35:05 -08:00
Dr. Kibitz
2e9558cbf9 Declare more variables as local 2014-02-16 01:05:24 -08:00
Jordan Harband
13781f242b Create a colorize_version function that doesn't include the padding, for nvm version 2014-02-15 18:12:24 -08:00
Jordan Harband
b6469ee186 Preventing an extra leading newline. 2014-02-15 18:12:24 -08:00
Jordan Harband
304cc29cf0 Fixing indentation and adding a trailing newline. 2014-02-15 16:02:27 -08:00
Jordan Harband
0d5ee024d1 Merge pull request #356 from geekjuice/master
Change variable name to fix zsh parse issue
2014-02-11 20:38:09 -08:00
Nicholas Hwang
9a88e3656c Change variable name to fix zsh parse issue 2014-02-11 22:55:02 -05:00
Jordan Harband
c19535a3f5 Merge pull request #354 from simontabor/patch-1
don't curl if version is specified + installed
2014-02-07 10:32:23 -08:00
Simon Tabor
9af7409e4a don't curl if version is specified + installed
Removes CURL to match the version pattern if an explicit version (e.g. `v0.10.25`) is specified and already installed.
2014-02-06 13:02:57 +00:00
Jordan Harband
eca6118023 Merge pull request #352 from gdi2290/patch-1
update copyright year range in readme
2014-02-03 19:30:52 -08:00
PatrickJS
50485d641b update copyright year range in readme 2014-02-03 17:07:56 -08:00
Jordan Harband
cd378cb170 Merge pull request #351 from gdi2290/patch-1
update copyright year range
2014-02-03 14:27:25 -08:00
PatrickJS
db7e0976f2 update copyright year range 2014-02-03 13:41:27 -08:00
Jordan Harband
ecb7a15baa Using our conventional NVM_ prefix for env vars.
Per https://github.com/creationix/nvm/pull/245#issuecomment-33821443
2014-01-31 10:01:37 -08:00
Jordan Harband
5f225cd625 Merge pull request #245 from rgbkrk/mirror_z
Add mirror option for node binaries. Relates to #255.
2014-01-30 21:25:46 -08:00
Kyle Kelley
8599ea29f9 Add dist to path, add docs 2014-01-30 19:22:44 -08:00
Kyle Kelley
b1d0cfa77b Added mirror option for node binaries 2014-01-30 19:16:36 -08:00
Jordan Harband
a0a2ee4414 Merge pull request #349 from zyxar/master
Fixes #346
2014-01-14 21:59:30 -08:00
Markus Z
60e66fa7be Fixes #346 2014-01-15 12:48:08 +08:00
Jordan Harband
45eff43cd0 Merge pull request #342 from txgruppi/master
export NODE_PATH on nvm use
2014-01-13 21:08:17 -08:00
Tarcisio Gruppi
eb588566f2 Removed PREVIOUS_NODE_PATH 2014-01-13 09:15:45 -02:00
Jordan Harband
17daa68a35 Merge pull request #344 from dhoppe/patch-1
Update nvm.sh
2014-01-03 10:16:53 -08:00
Dennis Hoppe
47c87b8478 Update nvm.sh
Examples should point to latest stable release. ;)
2014-01-03 14:45:46 +01:00
Tarcisio Gruppi
58dafdaedd Update NODE_PATH on use, run and deactivate 2014-01-01 02:04:37 -02:00
Tarcisio Gruppi
4d2faba9af export NODE_PATH on nvm use 2013-12-31 22:35:19 -02:00
Jordan Harband
bc4c5644f5 Merge pull request #335 from naartjie/#299
fix copy-packages in zsh
2013-12-26 11:02:28 -08:00
Marcin Jekot
950da2b836 Merge branch 'master' into #299 2013-12-25 18:14:24 +02:00
Jordan Harband
2459843b92 Merge pull request #279 from frasertweedale/fix/readme-shell-names
readme: be inclusive of zsh when discussing shells
2013-12-23 14:16:42 -08:00
Fraser Tweedale
58033251fd readme: be inclusive of zsh when discussing shells
Much of the discussion in the README pertains to zsh as much as
bash, so include a specific reference to ~/.zshrc and remove one
explicit reference to bash.
2013-12-24 07:24:31 +10:00
Jordan Harband
8df2dd2ba8 Merge pull request #278 from frasertweedale/fix/manpath
fix MANPATH generation on FreeBSD
2013-12-23 10:11:06 -08:00
Fraser Tweedale
591a3bb19d fix MANPATH generation on FreeBSD
On FreeBSD, if MANPATH is set it is used verbatim; configuration
files are completely ignored.  Therefore, setting MANPATH to (only)
the nvm man dir makes system man pages unreachable.

To get around this, before doing anything else to MANPATH, if it is
empty set it to the output of manpath(1).

One further complication: FreeBSD automatically adds a path to the
man pages path for each path in PATH that ends in "/bin", which
causes "~/.nvm/$VERSION/man" to be added.  This interferes with the
subsequent substitution so strip this from MANPATH before the
substitution.
2013-12-23 21:31:18 +10:00
Marcin Jekot
679c71650f fix copy-packages in zsh
fixes #299, finally, using the local var syntax
2013-12-18 17:21:00 +02:00
Jordan Harband
5c7996da5b Merge pull request #332 from ljharb/add_package_json
Add package json
2013-12-17 13:17:52 -08:00
Jordan Harband
9021cf579a Updating the README. 2013-12-17 13:12:05 -08:00
Jordan Harband
7afe2c5e2d Add a package.json. 2013-12-17 13:12:05 -08:00
Jordan Harband
8143f5a618 ignore more urchin output. 2013-12-17 13:07:52 -08:00
Jordan Harband
c211357e70 Ignore node_modules. 2013-12-17 13:07:02 -08:00
Jordan Harband
3eb09ab984 Merge pull request #330 from mibamur/patch-1
Update nvm.sh
2013-12-17 10:25:24 -08:00
Michael
670870e211 Update nvm.sh
fix#https://github.com/creationix/nvm/pull/330
2013-12-18 02:07:02 +09:00
Michael
74ca011704 Update nvm.sh
fix https://github.com/creationix/nvm/pull/330
2013-12-18 02:06:23 +09:00
Jordan Harband
83c5b6286d Add nvm current to nvm help. Relates to #205. 2013-12-16 23:40:47 -08:00
Jordan Harband
d7015c7f65 Merge pull request #205 from deiga/add-current-command
Added command to get current nvm environment.
2013-12-16 23:39:23 -08:00
Timo Sand
4ca71d81cf Changed test according to comments 2013-12-17 08:28:31 +02:00
Jordan Harband
ed69b5cc71 Merge pull request #331 from deiga/patch-1
Update README.markdown
2013-12-16 22:06:54 -08:00
Timo Sand
f9d5a85f05 Merge branch 'master' into add-current-command 2013-12-17 08:06:16 +02:00
Timo Sand
1f3ea299fa Update README.markdown 2013-12-17 08:01:06 +02:00
Michael
b2ef0cb14c Update nvm.sh
Fix - this line should be nvm use 0.10 - no 'v', and no incremental version number.
2013-12-16 23:25:50 +09:00
Michael
59c4dc735a Update nvm.sh
small fix fo nvm help info
2013-12-16 05:04:14 +09:00
Jordan Harband
ce7d2e7618 Merge pull request #328 from naartjie/master
fix copy-packages in zsh (without breaking sh and bash). Closes #223, fixes #299.
2013-12-15 10:32:41 -08:00
Marcin Jekot
4df45ac51a merge in changes from creationix/nvm 2013-12-15 11:27:15 +02:00
Jordan Harband
8573b95a2d Merge pull request #327 from stuartf/issue-314
fix copy-packages
2013-12-13 15:37:28 -08:00
Marcin Jekot
94fff5c923 fix copy-packages in zsh (without breaking sh and bash) 2013-12-14 01:14:34 +02:00
D. Stuart Freeman
56e32888ea fix copy-packages 2013-12-12 10:52:43 -05:00
Jordan Harband
b186b6327a Merge pull request #326 from koenpunt/has-command-helper
helper method for testing existence of commands
2013-12-12 02:21:52 -08:00
Koen Punt
e99fc43ab2 helper method for testing existence of commands 2013-12-12 10:46:40 +01:00
Jordan Harband
cf515c4ff8 Merge pull request #324 from hurrymaplelad/quiet_type
Slurp stderr from  test unsetopt
2013-12-11 18:32:06 -08:00
Adam Hull
037f52a55b Slurp test unsetopt stderr 2013-12-11 15:23:19 -08:00
Jordan Harband
b714db7a95 Merge pull request #322 from koenpunt/fix-unsetopt-test
Universal test of unsetopt command. Closes #300
2013-12-11 09:28:58 -08:00
Koen Punt
aba4346a86 Universal test of unsetopt command
According to http://stackoverflow.com/a/7522866/189431 it should work in "bash, zsh, ksh and sh (as provided by dash)".
2013-12-11 13:49:58 +01:00
Timo Sand
dc7a42062e Added test for nvm current 2013-10-10 07:58:51 +03:00
Timo Sand
dd157129a6 Added command to get current nvm environment. 2013-10-10 07:56:57 +03:00
Harald Glatt
2eddca3d9f Remove unneeded shebang in nvm.sh 2013-07-23 17:24:07 +02:00
Harald Glatt
6a6e435855 Switch from /bin/sh to /bin/bash
You have bashisms in your script and /bin/sh might not always be bash. In that case the script would fail (for example on Ubuntu).
2013-07-21 08:17:51 +02:00
38 changed files with 797 additions and 361 deletions

6
.gitignore vendored
View File

@@ -4,7 +4,11 @@ v*
alias
# For testing
bak
test/bak
.urchin.log
.urchin_stdout
node_modules/
.DS_Store

View File

@@ -1,3 +1,4 @@
src
v*
alias

8
.travis.yml Normal file
View File

@@ -0,0 +1,8 @@
language: c # defaults to ruby
install:
- sudo apt-get install ksh zsh -y
before_script:
- curl -o /tmp/urchin https://raw.githubusercontent.com/scraperwiki/urchin/master/urchin && chmod +x /tmp/urchin
script:
- NVM_DIR=$TRAVIS_BUILD_DIR make URCHIN=/tmp/urchin test

15
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,15 @@
Thanks for contributing to `nvm`!
We love pull requests, they're our favorite.
However, before submitting, please review the following:
- Please include tests. Changes with tests will be merged very quickly.
- Please manually confirm that your changes, and all tests, pass in `bash`, `sh`, and `zsh`. We hope to soon automatically run all these tests, but in the meantime, we have to rely on each contributor doing so.
- Please maintain consistent whitespace - 2-space indentation, trailing newlines in all files, etc.
- Any time you make a change to your PR, please rebase freshly on top of master. Nobody likes merge commits.
Even if you don't have all of these items covered, please still feel free to submit a PR! Someone else may be inspired and volunteer to complete it for you.
Thanks again!

View File

@@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2010-2013 Tim Caswell
Copyright (c) 2010-2014 Tim Caswell
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in

16
Makefile Normal file
View File

@@ -0,0 +1,16 @@
URCHIN=`which urchin`
SHELLS=sh bash dash ksh zsh
.PHONY: $(SHELLS) test
fast: $(SHELLS)
$(SHELLS):
@printf '\n\033[0;34m%s\033[0m\n' "Running tests in $@"
@$@ $(URCHIN) -f test/fast
test: fast
@$(URCHIN) -f test/slow
default: test

View File

@@ -1,4 +1,4 @@
# Node Version Manager
# Node Version Manager [![Build Status](https://travis-ci.org/creationix/nvm.svg?branch=master)][3]
## Installation
@@ -6,16 +6,19 @@ First you'll need to make sure your system has a c++ compiler. For OSX, XCode w
### Install script
To install you could use the [install script](https://github.com/creationix/nvm/blob/master/install.sh) (requires Git) using cURL:
To install you could use the [install script][2] using cURL:
curl https://raw.github.com/creationix/nvm/master/install.sh | sh
curl https://raw.githubusercontent.com/creationix/nvm/v0.7.0/install.sh | sh
or Wget:
wget -qO- https://raw.github.com/creationix/nvm/master/install.sh | sh
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.7.0/install.sh | sh
<sub>The script clones the nvm repository to `~/.nvm` and adds the source line to your profile (`~/.bash_profile` or `~/.profile`).</sub>
<sub>The script clones the nvm repository to `~/.nvm` and adds the source line to your profile (`~/.bash_profile`, `~/.zshrc` or `~/.profile`).</sub>
You can customize the install source, directory and profile using the `NVM_SOURCE`, `NVM_DIR` and `NVM_PROFILE` variables. Eg: `curl ... | NVM_DIR=/usr/local/nvm sh` for a global install.
<sub>*NB. The installer can use Git, cURL or Wget to download NVM, whatever is available.*</sub>
### Manual install
@@ -25,15 +28,18 @@ Or if you have `git` installed, then just clone it:
git clone https://github.com/creationix/nvm.git ~/.nvm
To activate nvm, you need to source it from your bash shell
To activate nvm, you need to source it from your shell:
source ~/.nvm/nvm.sh
I always add this line to my `~/.bashrc` or `~/.profile` file to have it automatically sourced upon login.
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.
## Usage
You can create an `.nvmrc` file containing version number in the project root directory (or any parent directory).
`nvm use`, `nvm install`, and `nvm run` will all respect an `.nvmrc` file.
To download, compile, and install the latest v0.10.x release of node, do this:
nvm install 0.10
@@ -42,13 +48,9 @@ And then in any new shell just use the installed version:
nvm use 0.10
You can create an `.nvmrc` file containing version number in the project root folder; run the following command to switch versions:
nvm use
Or you can just run it:
nvm run 0.10
nvm run 0.10 --version
If you want to see what versions are installed:
@@ -66,12 +68,19 @@ To set a default Node version to be used in any new shell, use the alias 'defaul
nvm alias default 0.10
To use a mirror of the node binaries, set `$NVM_NODEJS_ORG_MIRROR`:
export NVM_NODEJS_ORG_MIRROR=http://nodejs.org/dist
nvm install 0.10
NVM_NODEJS_ORG_MIRROR=http://nodejs.org/dist nvm install 0.10
## License
nvm is released under the MIT license.
Copyright (C) 2010-2013 Tim Caswell
Copyright (C) 2010-2014 Tim Caswell
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
@@ -80,27 +89,24 @@ The above copyright notice and this permission notice shall be included in all c
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
## Running tests
Tests are written in [Urchin](https://github.com/scraperwiki/urchin). Install Urchin like so.
Tests are written in [Urchin]. Install Urchin (and other dependencies) like so:
wget -O /usr/local/bin https://raw.github.com/scraperwiki/urchin/0c6837cfbdd0963903bf0463b05160c2aecc22ef/urchin
chmod +x /usr/local/bin/urchin
(Or put it some other place in your PATH.)
npm install
There are slow tests and fast tests. The slow tests do things like install node
and check that the right versions are used. The fast tests fake this to test
things like aliases and uninstalling. From the root of the nvm git repository,
run the fast tests like this.
urchin test/fast
npm run test/fast
Run the slow tests like this.
urchin test/slow
npm run test/slow
Run all of the tests like this
urchin test
npm test
Nota bene: Avoid running nvm while the tests are running.
@@ -126,17 +132,17 @@ nvm alias
default
$ nvm alias my_alias [tab][tab]
v0.4.11 v0.4.12 v0.6.14
v0.6.21 v0.8.26 v0.10.28
nvm use
$ nvm use [tab][tab]
my_alias default v0.4.11 v0.4.12 v0.6.14
my_alias default v0.6.21 v0.8.26 v0.10.28
nvm uninstall
$ nvm uninstall [tab][tab]
my_alias default v0.4.11 v0.4.12 v0.6.14
my_alias default v0.6.21 v0.8.26 v0.10.28
## Problems
@@ -156,3 +162,8 @@ 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.7.0/install.sh
[3]: https://travis-ci.org/creationix/nvm
[Urchin]: https://github.com/scraperwiki/urchin

View File

@@ -87,3 +87,4 @@ if [[ -n ${ZSH_VERSION-} ]]; then
fi
complete -o default -o nospace -F __nvm nvm

View File

@@ -1,59 +0,0 @@
#!/bin/bash
function fatalExit (){
echo "$@" && exit 1;
}
# an alternative URL that could be used: https://github.com/creationix/nvm/tarball/master
if [ "$NVM_SOURCE" == "" ]; then
NVM_SOURCE="https://raw.github.com/creationix/nvm/master/nvm.sh"
fi
if [ "$NVM_DIR" == "" ]; then
NVM_DIR="$HOME/.nvm"
fi
# Downloading to $NVM_DIR
mkdir -p "$NVM_DIR"
pushd "$NVM_DIR" > /dev/null
echo -ne "=> Downloading... "
curl --silent "$NVM_SOURCE" -o nvm.sh || fatalExit "Failed";
echo "Downloaded"
popd > /dev/null
# Detect profile file, .bash_profile has precedence over .profile
if [ ! -z "$1" ]; then
PROFILE="$1"
else
if [ -f "$HOME/.bash_profile" ]; then
PROFILE="$HOME/.bash_profile"
elif [ -f "$HOME/.profile" ]; then
PROFILE="$HOME/.profile"
fi
fi
SOURCE_STR="[[ -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"
else
echo "=> Profile $PROFILE not found"
fi
echo "=> Append the following line to the correct file yourself"
echo
echo "\t$SOURCE_STR"
echo
echo "=> Close and reopen your terminal to start using NVM"
exit
fi
if ! grep -qc 'nvm.sh' $PROFILE; then
echo "=> Appending source string to $PROFILE"
echo "" >> "$PROFILE"
echo $SOURCE_STR >> "$PROFILE"
else
echo "=> Source string already in $PROFILE"
fi
echo "=> Close and reopen your terminal to start using NVM"

View File

@@ -1,65 +1,130 @@
#!/bin/bash
NVM_DIR="$HOME/.nvm"
set -e
if ! hash git 2>/dev/null; then
echo >&2 "You need to install git - visit http://git-scm.com/downloads"
echo >&2 "or, use install-gitless.sh instead."
exit 1
has() {
type "$1" > /dev/null 2>&1
return $?
}
if [ -z "$NVM_DIR" ]; then
NVM_DIR="$HOME/.nvm"
fi
if [ -d "$NVM_DIR" ]; then
echo "=> NVM is already installed in $NVM_DIR, trying to update"
echo -ne "\r=> "
cd $NVM_DIR && git pull
if ! has "curl"; then
if has "wget"; then
# Emulate curl with wget
curl() {
ARGS="$* "
ARGS=${ARGS/-s /-q }
ARGS=${ARGS/-o /-O }
wget $ARGS
}
fi
fi
install_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 -e "\r=> \c"
cd "$NVM_DIR" && git pull 2> /dev/null || {
echo >&2 "Failed to update nvm, run 'git pull' in $NVM_DIR yourself.."
}
else
# Cloning to $NVM_DIR
echo "=> Downloading nvm from git to '$NVM_DIR'"
echo -e "\r=> \c"
mkdir -p "$NVM_DIR"
git clone "$NVM_SOURCE" "$NVM_DIR"
fi
}
install_as_script() {
if [ -z "$NVM_SOURCE" ]; then
NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/master/nvm.sh"
fi
# 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"
else
echo "=> Downloading nvm as script to '$NVM_DIR'"
fi
curl -s "$NVM_SOURCE" -o "$NVM_DIR/nvm.sh" || {
echo >&2 "Failed to download '$NVM_SOURCE'.."
return 1
}
}
if [ -z "$METHOD" ]; then
# Autodetect install method
if has "git"; then
install_from_git
elif has "curl"; then
install_as_script
else
echo >&2 "You need git, curl or wget to install nvm"
exit 1
fi
else
# Cloning to $NVM_DIR
git clone https://github.com/creationix/nvm.git $NVM_DIR
if [ "$METHOD" = "git" ]; then
if ! has "git"; then
echo >&2 "You need git to install nvm"
exit 1
fi
install_from_git
fi
if [ "$METHOD" = "script" ]; then
if ! has "curl"; then
echo >&2 "You need curl or wget to install nvm"
exit 1
fi
install_as_script
fi
fi
echo
# Detect profile file, .bash_profile has precedence over .profile
if [ ! -z "$1" ]; then
PROFILE="$1"
else
# Detect profile file if not specified as environment variable (eg: PROFILE=~/.myprofile).
if [ -z "$PROFILE" ]; then
if [ -f "$HOME/.bash_profile" ]; then
PROFILE="$HOME/.bash_profile"
PROFILE="$HOME/.bash_profile"
elif [ -f "$HOME/.zshrc" ]; then
PROFILE="$HOME/.zshrc"
PROFILE="$HOME/.zshrc"
elif [ -f "$HOME/.profile" ]; then
PROFILE="$HOME/.profile"
PROFILE="$HOME/.profile"
fi
fi
SOURCE_STR="[ -s \$HOME/.nvm/nvm.sh ] && . \$HOME/.nvm/nvm.sh # This loads NVM"
SOURCE_STR="[ -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 $HOME/.bash_profile and $HOME/.profile"
echo "=> Profile not found. Tried ~/.bash_profile ~/.zshrc and ~/.profile."
echo "=> Create one of them and run this script again"
else
echo "=> Profile $PROFILE not found"
echo "=> Profile $PROFILE not found"
echo "=> Create it (touch $PROFILE) and run this script again"
fi
echo "=> Run this script again after running the following:"
echo " OR"
echo "=> Append the following line to the correct file yourself:"
echo
echo "\ttouch $HOME/.profile"
echo " $SOURCE_STR"
echo
echo "-- OR --"
echo
echo "=> Append the following line to the correct file yourself"
echo
echo "\t$SOURCE_STR"
echo
echo "=> Close and reopen your terminal afterwards to start using NVM"
exit
fi
if ! grep -qc 'nvm.sh' $PROFILE; then
echo "=> Appending source string to $PROFILE"
echo "" >> "$PROFILE"
echo $SOURCE_STR >> "$PROFILE"
else
echo "=> Source string already in $PROFILE"
if ! grep -qc 'nvm.sh' $PROFILE; then
echo "=> Appending source string to $PROFILE"
echo "" >> "$PROFILE"
echo $SOURCE_STR >> "$PROFILE"
else
echo "=> Source string already in $PROFILE"
fi
fi
echo "=> Close and reopen your terminal to start using NVM"
echo "=> Close and reopen your terminal to start using nvm"

14
nvm-exec Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/bash
DIR="$(command cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$DIR/nvm.sh"
if [ -n "$NODE_VERSION" ]; then
nvm use $NODE_VERSION || (echo "NODE_VERSION not set" && exit 127)
else
nvm use || (echo "No .nvmrc file found" && exit 127)
fi
exec $@

505
nvm.sh Executable file → Normal file
View File

@@ -1,5 +1,3 @@
#!/bin/sh
# Node Version Manager
# Implemented as a bash function
# To use source this file from your bash profile
@@ -7,135 +5,199 @@
# Implemented by Tim Caswell <tim@creationix.com>
# with much bash help from Matthew Ranney
NVM_SCRIPT_SOURCE="$_"
nvm_has() {
type "$1" > /dev/null 2>&1
return $?
}
# Make zsh glob matching behave same as bash
# This fixes the "zsh: no matches found" errors
if [ ! -z "$(which unsetopt 2>/dev/null)" ]; then
unsetopt nomatch 2>/dev/null
NVM_CD_FLAGS="-q"
if nvm_has "unsetopt"; then
unsetopt nomatch 2>/dev/null
NVM_CD_FLAGS="-q"
fi
# Auto detect the NVM_DIR
if [ ! -d "$NVM_DIR" ]; then
export NVM_DIR=$(cd $NVM_CD_FLAGS $(dirname ${BASH_SOURCE[0]:-$0}) > /dev/null && pwd)
# Auto detect the NVM_DIR when not set
if [ -z "$NVM_DIR" ]; then
if [ -n "$BASH_SOURCE" ]; then
NVM_SCRIPT_SOURCE="${BASH_SOURCE[0]}"
fi
export NVM_DIR=$(cd $NVM_CD_FLAGS $(dirname "${NVM_SCRIPT_SOURCE:-$0}") > /dev/null && pwd)
fi
unset NVM_SCRIPT_SOURCE 2> /dev/null
# Setup mirror location if not already set
if [ -z "$NVM_NODEJS_ORG_MIRROR" ]; then
export NVM_NODEJS_ORG_MIRROR="http://nodejs.org/dist"
fi
nvm_set_nullglob() {
if type setopt > /dev/null 2>&1; then
# Zsh
setopt NULL_GLOB
else
# Bash
shopt -s nullglob
# Traverse up in directory tree to find containing folder
nvm_find_up() {
local path
path=$PWD
while [ "$path" != "" ] && [ ! -f "$path/$1" ]; do
path=${path%/*}
done
echo "$path"
}
nvm_find_nvmrc() {
local dir="$(nvm_find_up '.nvmrc')"
if [ -e "$dir/.nvmrc" ]; then
echo "$dir/.nvmrc"
fi
}
# Obtain nvm version from rc file
rc_nvm_version() {
if [ -e .nvmrc ]; then
RC_VERSION=`cat .nvmrc | head -n 1`
echo "Found .nvmrc files with version <$RC_VERSION>"
nvm_rc_version() {
local NVMRC_PATH="$(nvm_find_nvmrc)"
if [ -e "$NVMRC_PATH" ]; then
NVM_RC_VERSION=`cat "$NVMRC_PATH" | head -n 1`
echo "Found '$NVMRC_PATH' with version <$NVM_RC_VERSION>"
fi
}
# Expand a version using the version cache
nvm_version() {
local PATTERN=$1
# The default version is the current one
if [ ! "$PATTERN" ]; then
PATTERN='current'
fi
local PATTERN=$1
local VERSION
# The default version is the current one
if [ -z "$PATTERN" ]; then
PATTERN='current'
fi
VERSION=`nvm_ls $PATTERN | tail -n1`
echo "$VERSION"
VERSION=`nvm_ls $PATTERN | tail -n1`
echo "$VERSION"
if [ "$VERSION" = 'N/A' ]; then
return
fi
if [ "$VERSION" = 'N/A' ]; then
return
fi
}
nvm_remote_version() {
local PATTERN=$1
VERSION=`nvm_ls_remote $PATTERN | tail -n1`
echo "$VERSION"
local PATTERN=$1
local VERSION
VERSION=`nvm_ls_remote $PATTERN | tail -n1`
echo "$VERSION"
if [ "$VERSION" = 'N/A' ]; then
return
fi
if [ "$VERSION" = 'N/A' ]; then
return
fi
}
nvm_normalize_version() {
echo "$1" | sed -e 's/^v//' | awk -F. '{ printf("%d%03d%03d\n", $1,$2,$3); }'
}
nvm_format_version() {
echo "$1" | sed -e 's/^\([0-9]\)/v\1/g'
}
nvm_strip_path() {
echo "$1" | sed -e "s#$NVM_DIR/[^/]*$2[^:]*:##g" -e "s#:$NVM_DIR/[^/]*$2[^:]*##g" -e "s#$NVM_DIR/[^/]*$2[^:]*##g"
}
nvm_prepend_path() {
if [ -z "$1" ]; then
echo "$2"
else
echo "$2:$1"
fi
}
nvm_binary_available() {
# binaries started with node 0.8.6
local MINIMAL="0.8.6"
local VERSION=$1
[ $(nvm_normalize_version $VERSION) -ge $(nvm_normalize_version $MINIMAL) ]
}
nvm_ls() {
local PATTERN=$1
local VERSIONS=''
if [ "$PATTERN" = 'current' ]; then
echo `node -v 2>/dev/null`
return
fi
if [ -f "$NVM_DIR/alias/$PATTERN" ]; then
nvm_version `cat $NVM_DIR/alias/$PATTERN`
return
fi
# If it looks like an explicit version, don't do anything funny
if [[ "$PATTERN" == v?*.?*.?* ]]; then
VERSIONS="$PATTERN"
else
VERSIONS=`find "$NVM_DIR/" -maxdepth 1 -type d -name "v$PATTERN*" -exec basename '{}' ';' \
| sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n`
fi
if [ ! "$VERSIONS" ]; then
echo "N/A"
return
fi
echo "$VERSIONS"
local PATTERN=$1
local VERSIONS=''
if [ "$PATTERN" = 'current' ]; then
echo `node -v 2>/dev/null`
return
fi
if [ -f "$NVM_DIR/alias/$PATTERN" ]; then
nvm_version `cat $NVM_DIR/alias/$PATTERN`
return
fi
# If it looks like an explicit version, don't do anything funny
if [ `expr "$PATTERN" : "v[[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*$"` != 0 ]; then
VERSIONS="$PATTERN"
else
VERSIONS=`find "$NVM_DIR/" -maxdepth 1 -type d -name "$(nvm_format_version $PATTERN)*" -exec basename '{}' ';' \
| sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n`
fi
if [ -z "$VERSIONS" ]; then
echo "N/A"
return
fi
echo "$VERSIONS"
return
}
nvm_ls_remote() {
local PATTERN=$1
local VERSIONS
if [ "$PATTERN" ]; then
if echo "${PATTERN}" | \grep -v '^v' ; then
PATTERN=v$PATTERN
fi
else
PATTERN=".*"
fi
VERSIONS=`curl -s http://nodejs.org/dist/ \
| \egrep -o 'v[0-9]+\.[0-9]+\.[0-9]+' \
| \grep -w "${PATTERN}" \
| sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n`
if [ ! "$VERSIONS" ]; then
echo "N/A"
return
fi
echo "$VERSIONS"
local PATTERN=$1
local VERSIONS
local GREP_OPTIONS=''
if [ -n "$PATTERN" ]; then
PATTERN=`nvm_format_version "$PATTERN"`
else
PATTERN=".*"
fi
VERSIONS=`curl -s $NVM_NODEJS_ORG_MIRROR/ \
| \egrep -o 'v[0-9]+\.[0-9]+\.[0-9]+' \
| \grep -w "${PATTERN}" \
| sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n`
if [ -z "$VERSIONS" ]; then
echo "N/A"
return
fi
echo "$VERSIONS"
return
}
nvm_checksum() {
if [ "$1" = "$2" ]; then
return
elif [ -z $2 ]; then
echo 'Checksums empty' #missing in raspberry pi binary
return
else
echo 'Checksums do not match.'
return 1
fi
if nvm_has "shasum"; then
checksum=$(shasum $1 | awk '{print $1}')
elif nvm_has "sha1"; then
checksum=$(sha1 -q $1)
else
checksum=$(sha1sum $1 | awk '{print $1}')
fi
if [ "$checksum" = "$2" ]; then
return
elif [ -z "$2" ]; then
echo 'Checksums empty' #missing in raspberry pi binary
return
else
echo 'Checksums do not match.'
return 1
fi
}
print_versions() {
local OUTPUT=''
local PADDED_VERSION=''
for VERSION in $1; do
PADDED_VERSION=`printf '%10s' $VERSION`
if [[ -d "$NVM_DIR/$VERSION" ]]; then
PADDED_VERSION="\033[0;34m$PADDED_VERSION\033[0m"
fi
OUTPUT="$OUTPUT\n$PADDED_VERSION"
done
echo -e "$OUTPUT"
nvm_print_versions() {
local VERSION
local FORMAT
local CURRENT=`nvm_version current`
echo "$1" | while read VERSION; do
if [ "$VERSION" = "$CURRENT" ]; then
FORMAT='\033[0;32m-> %9s\033[0m'
elif [ -d "$NVM_DIR/$VERSION" ]; then
FORMAT='\033[0;34m%12s\033[0m'
else
FORMAT='%12s'
fi
printf "$FORMAT\n" $VERSION
done
}
nvm() {
@@ -148,6 +210,7 @@ nvm() {
local uname="$(uname -a)"
local os=
local arch="$(uname -m)"
local GREP_OPTIONS=''
case "$uname" in
Linux\ *) os=linux ;;
Darwin\ *) os=darwin ;;
@@ -163,6 +226,7 @@ nvm() {
# initialize local variables
local VERSION
local ADDITIONAL_PARAMETERS
local ALIAS
case $1 in
"help" )
@@ -171,10 +235,12 @@ nvm() {
echo
echo "Usage:"
echo " nvm help Show this message"
echo " nvm install [-s] <version> Download and install a <version>"
echo " nvm --version Print out the latest released version of nvm"
echo " nvm install [-s] <version> Download and install a <version>, [-s] from source. Uses .nvmrc if available"
echo " nvm uninstall <version> Uninstall a version"
echo " nvm use <version> Modify PATH to use <version>"
echo " nvm run <version> [<args>] Run <version> with <args> as arguments"
echo " nvm use <version> Modify PATH to use <version>. Uses .nvmrc if available"
echo " nvm run <version> [<args>] Run <version> with <args> as arguments. Uses .nvmrc if available for <version>"
echo " nvm current Display currently activated version"
echo " nvm ls List installed versions"
echo " nvm ls <version> List versions matching a given description"
echo " nvm ls-remote List remote versions available for install"
@@ -185,10 +251,13 @@ nvm() {
echo " nvm copy-packages <version> Install global NPM packages contained in <version> to current version"
echo
echo "Example:"
echo " nvm install v0.4.12 Install a specific version number"
echo " nvm use 0.2 Use the latest available 0.2.x release"
echo " nvm run 0.4.12 myApp.js Run myApp.js using node v0.4.12"
echo " nvm alias default 0.4 Auto use the latest installed v0.4.x version"
echo " nvm install v0.10.24 Install a specific version number"
echo " nvm use 0.10 Use the latest available 0.10.x release"
echo " nvm run 0.10.24 myApp.js Run myApp.js using node v0.10.24"
echo " nvm alias default 0.10.24 Set default node version on a shell"
echo
echo "Note:"
echo " to remove, delete or uninstall nvm - just remove ~/.nvm, ~/.npm and ~/.bower folders"
echo
;;
@@ -199,20 +268,22 @@ nvm() {
local url
local sum
local tarball
local shasum='shasum'
local nobinary
local version_not_provided=0
local provided_version
if [ ! `\which curl` ]; then
if ! nvm_has "curl"; then
echo 'NVM Needs curl to proceed.' >&2;
fi
if [ ! `\which shasum` ]; then
shasum='sha1sum'
return 1
fi
if [ $# -lt 2 ]; then
nvm help
return
version_not_provided=1
nvm_rc_version
if [ -z "$NVM_RC_VERSION" ]; then
nvm help
return
fi
fi
shift
@@ -224,10 +295,19 @@ nvm() {
fi
if [ "$os" = "freebsd" ]; then
nobinary=1
nobinary=1
fi
VERSION=`nvm_remote_version $1`
provided_version=$1
if [ -z "$provided_version" ]; then
if [ $version_not_provided -ne 1 ]; then
nvm_rc_version
fi
provided_version="$NVM_RC_VERSION"
fi
[ -d "$NVM_DIR/$provided_version" ] && echo "$provided_version is already installed." && return
VERSION=`nvm_remote_version $provided_version`
ADDITIONAL_PARAMETERS=''
shift
@@ -238,29 +318,31 @@ nvm() {
shift
done
[ -d "$NVM_DIR/$VERSION" ] && echo "$VERSION is already installed." && return
if [ -d "$NVM_DIR/$VERSION" ]; then
echo "$VERSION is already installed."
nvm use "$VERSION"
return $?
fi
if [ "$VERSION" = "N/A" ]; then
echo "Version '$provided_version' not found - try \`nvm ls-remote\` to browse available versions."
return 3
fi
# skip binary install if no binary option specified.
if [ $nobinary -ne 1 ]; then
# shortcut - try the binary if possible.
if [ -n "$os" ]; then
binavail=
# binaries started with node 0.8.6
case "$VERSION" in
v0.8.[012345]) binavail=0 ;;
v0.[1234567].*) binavail=0 ;;
*) binavail=1 ;;
esac
if [ $binavail -eq 1 ]; then
if nvm_binary_available "$VERSION"; then
t="$VERSION-$os-$arch"
url="http://nodejs.org/dist/$VERSION/node-${t}.tar.gz"
sum=`curl -s http://nodejs.org/dist/$VERSION/SHASUMS.txt | \grep node-${t}.tar.gz | awk '{print $1}'`
url="$NVM_NODEJS_ORG_MIRROR/$VERSION/node-${t}.tar.gz"
sum=`curl -s $NVM_NODEJS_ORG_MIRROR/$VERSION/SHASUMS.txt | \grep node-${t}.tar.gz | awk '{print $1}'`
local tmpdir="$NVM_DIR/bin/node-${t}"
local tmptarball="$tmpdir/node-${t}.tar.gz"
if (
mkdir -p "$tmpdir" && \
curl -L -C - --progress-bar $url -o "$tmptarball" && \
nvm_checksum `${shasum} "$tmptarball" | awk '{print $1}'` $sum && \
nvm_checksum "$tmptarball" $sum && \
tar -xzf "$tmptarball" -C "$tmpdir" --strip-components 1 && \
rm -f "$tmptarball" && \
mv "$tmpdir" "$NVM_DIR/$VERSION"
@@ -282,36 +364,37 @@ nvm() {
sum=''
make='make'
if [ "$os" = "freebsd" ]; then
make='gmake'
make='gmake'
MAKE_CXX="CXX=c++"
fi
local tmpdir="$NVM_DIR/src"
local tmptarball="$tmpdir/node-$VERSION.tar.gz"
if [ "`curl -Is "http://nodejs.org/dist/$VERSION/node-$VERSION.tar.gz" | \grep '200 OK'`" != '' ]; then
tarball="http://nodejs.org/dist/$VERSION/node-$VERSION.tar.gz"
sum=`curl -s http://nodejs.org/dist/$VERSION/SHASUMS.txt | \grep node-$VERSION.tar.gz | awk '{print $1}'`
elif [ "`curl -Is "http://nodejs.org/dist/node-$VERSION.tar.gz" | \grep '200 OK'`" != '' ]; then
tarball="http://nodejs.org/dist/node-$VERSION.tar.gz"
if [ "`curl -Is "$NVM_NODEJS_ORG_MIRROR/$VERSION/node-$VERSION.tar.gz" | \grep '200 OK'`" != '' ]; then
tarball="$NVM_NODEJS_ORG_MIRROR/$VERSION/node-$VERSION.tar.gz"
sum=`curl -s $NVM_NODEJS_ORG_MIRROR/$VERSION/SHASUMS.txt | \grep node-$VERSION.tar.gz | awk '{print $1}'`
elif [ "`curl -Is "$NVM_NODEJS_ORG_MIRROR/node-$VERSION.tar.gz" | \grep '200 OK'`" != '' ]; then
tarball="$NVM_NODEJS_ORG_MIRROR/node-$VERSION.tar.gz"
fi
if (
[ ! -z $tarball ] && \
[ -n "$tarball" ] && \
mkdir -p "$tmpdir" && \
curl -L --progress-bar $tarball -o "$tmptarball" && \
if [ "$sum" = "" ]; then : ; else nvm_checksum `${shasum} "$tmptarball" | awk '{print $1}'` $sum; fi && \
nvm_checksum "$tmptarball" $sum && \
tar -xzf "$tmptarball" -C "$tmpdir" && \
cd "$tmpdir/node-$VERSION" && \
./configure --prefix="$NVM_DIR/$VERSION" $ADDITIONAL_PARAMETERS && \
$make && \
$make $MAKE_CXX && \
rm -f "$NVM_DIR/$VERSION" 2>/dev/null && \
$make install
$make $MAKE_CXX install
)
then
nvm use $VERSION
if ! which npm ; then
if ! nvm_has "npm" ; then
echo "Installing npm..."
if [[ "`expr match $VERSION '\(^v0\.1\.\)'`" != '' ]]; then
if [ "`expr "$VERSION" : '\(^v0\.1\.\)'`" != '' ]; then
echo "npm requires node v0.2.3 or higher"
elif [[ "`expr match $VERSION '\(^v0\.2\.\)'`" != '' ]]; then
if [[ "`expr match $VERSION '\(^v0\.2\.[0-2]$\)'`" != '' ]]; then
elif [ "`expr "$VERSION" : '\(^v0\.2\.\)'`" != '' ]; then
if [ "`expr "$VERSION" : '\(^v0\.2\.[0-2]$\)'`" != '' ]; then
echo "npm requires node v0.2.3 or higher"
else
curl https://npmjs.org/install.sh | clean=yes npm_install=0.2.19 sh
@@ -327,11 +410,12 @@ nvm() {
;;
"uninstall" )
[ $# -ne 2 ] && nvm help && return
if [[ $2 == `nvm_version` ]]; then
echo "nvm: Cannot uninstall currently-active node version, $2."
PATTERN=`nvm_format_version $2`
if [ "$PATTERN" = `nvm_version` ]; then
echo "nvm: Cannot uninstall currently-active node version, $PATTERN."
return 1
fi
VERSION=`nvm_version $2`
VERSION=`nvm_version $PATTERN`
if [ ! -d $NVM_DIR/$VERSION ]; then
echo "$VERSION version is not installed..."
return;
@@ -348,98 +432,141 @@ nvm() {
echo "Uninstalled node $VERSION"
# Rm any aliases that point to uninstalled version.
for A in `\grep -l $VERSION $NVM_DIR/alias/* 2>/dev/null`
for ALIAS in `\grep -l $VERSION $NVM_DIR/alias/* 2>/dev/null`
do
nvm unalias `basename $A`
nvm unalias `basename $ALIAS`
done
;;
"deactivate" )
if [[ $PATH == *$NVM_DIR/*/bin* ]]; then
export PATH=${PATH%$NVM_DIR/*/bin*}${PATH#*$NVM_DIR/*/bin:}
if [ `expr "$PATH" : ".*$NVM_DIR/.*/bin.*"` != 0 ] ; then
export PATH=`nvm_strip_path "$PATH" "/bin"`
hash -r
echo "$NVM_DIR/*/bin removed from \$PATH"
else
echo "Could not find $NVM_DIR/*/bin in \$PATH"
fi
if [[ $MANPATH == *$NVM_DIR/*/share/man* ]]; then
export MANPATH=${MANPATH%$NVM_DIR/*/share/man*}${MANPATH#*$NVM_DIR/*/share/man:}
if [ `expr "$MANPATH" : ".*$NVM_DIR/.*/share/man.*"` != 0 ] ; then
export MANPATH=`nvm_strip_path "$MANPATH" "/share/man"`
echo "$NVM_DIR/*/share/man removed from \$MANPATH"
else
echo "Could not find $NVM_DIR/*/share/man in \$MANPATH"
fi
if [ `expr "$NODE_PATH" : ".*$NVM_DIR/.*/lib/node_modules.*"` != 0 ] ; then
export NODE_PATH=`nvm_strip_path "$NODE_PATH" "/lib/node_modules"`
echo "$NVM_DIR/*/lib/node_modules removed from \$NODE_PATH"
else
echo "Could not find $NVM_DIR/*/lib/node_modules in \$NODE_PATH"
fi
;;
"use" )
if [ $# -eq 0 ]; then
nvm help
return
return 127
fi
if [ $# -eq 1 ]; then
rc_nvm_version
if [ ! -z $RC_VERSION ]; then
VERSION=`nvm_version $RC_VERSION`
nvm_rc_version
if [ -n "$NVM_RC_VERSION" ]; then
VERSION=`nvm_version $NVM_RC_VERSION`
fi
else
VERSION=`nvm_version $2`
fi
if [ -z $VERSION ]; then
if [ -z "$VERSION" ]; then
nvm help
return
return 127
fi
if [ -z $VERSION ]; then
if [ -z "$VERSION" ]; then
VERSION=`nvm_version $2`
fi
if [ ! -d "$NVM_DIR/$VERSION" ]; then
echo "$VERSION version is not installed yet"
return 1
fi
if [[ $PATH == *$NVM_DIR/*/bin* ]]; then
PATH=${PATH%$NVM_DIR/*/bin*}$NVM_DIR/$VERSION/bin${PATH#*$NVM_DIR/*/bin}
else
PATH="$NVM_DIR/$VERSION/bin:$PATH"
fi
if [[ $MANPATH == *$NVM_DIR/*/share/man* ]]; then
MANPATH=${MANPATH%$NVM_DIR/*/share/man*}$NVM_DIR/$VERSION/share/man${MANPATH#*$NVM_DIR/*/share/man}
else
MANPATH="$NVM_DIR/$VERSION/share/man:$MANPATH"
# Strip other version from PATH
PATH=`nvm_strip_path "$PATH" "/bin"`
# Prepend current version
PATH=`nvm_prepend_path "$PATH" "$NVM_DIR/$VERSION/bin"`
if [ -z "$MANPATH" ]; then
MANPATH=$(manpath)
fi
# Strip other version from MANPATH
MANPATH=`nvm_strip_path "$MANPATH" "/share/man"`
# Prepend current version
MANPATH=`nvm_prepend_path "$MANPATH" "$NVM_DIR/$VERSION/share/man"`
# Strip other version from NODE_PATH
NODE_PATH=`nvm_strip_path "$NODE_PATH" "/lib/node_modules"`
# Prepend current version
NODE_PATH=`nvm_prepend_path "$NODE_PATH" "$NVM_DIR/$VERSION/lib/node_modules"`
export PATH
hash -r
export MANPATH
export NODE_PATH
export NVM_PATH="$NVM_DIR/$VERSION/lib/node"
export NVM_BIN="$NVM_DIR/$VERSION/bin"
echo "Now using node $VERSION"
;;
"run" )
local provided_version
local has_checked_nvmrc=0
# run given version of node
if [ $# -lt 2 ]; then
nvm help
return
shift
if [ $# -lt 1 ]; then
nvm_rc_version && has_checked_nvmrc=1
if [ -n "$NVM_RC_VERSION" ]; then
VERSION=`nvm_version $NVM_RC_VERSION`
else
VERSION='N/A'
fi
if [ $VERSION = "N/A" ]; then
nvm help
return 127
fi
fi
VERSION=`nvm_version $2`
if [ ! -d $NVM_DIR/$VERSION ]; then
provided_version=$1
if [ -n "$provided_version" ]; then
VERSION=`nvm_version $provided_version`
if [ $VERSION = "N/A" ]; then
provided_version=''
if [ $has_checked_nvmrc -ne 1 ]; then
nvm_rc_version && has_checked_nvmrc=1
fi
VERSION=`nvm_version $NVM_RC_VERSION`
else
shift
fi
fi
if [ ! -d "$NVM_DIR/$VERSION" ]; then
echo "$VERSION version is not installed yet"
return;
fi
RUN_NODE_PATH=`nvm_strip_path "$NODE_PATH" "/lib/node_modules"`
RUN_NODE_PATH=`nvm_prepend_path "$NODE_PATH" "$NVM_DIR/$VERSION/lib/node_modules"`
echo "Running node $VERSION"
$NVM_DIR/$VERSION/bin/node "${@:3}"
NODE_PATH=$RUN_NODE_PATH $NVM_DIR/$VERSION/bin/node "$@"
;;
"ls" | "list" )
print_versions "`nvm_ls $2`"
nvm_print_versions "`nvm_ls $2`"
if [ $# -eq 1 ]; then
echo -ne "current: \t"; nvm_version current
nvm alias
fi
return
;;
"ls-remote" | "list-remote" )
print_versions "`nvm_ls_remote $2`"
nvm_print_versions "`nvm_ls_remote $2`"
return
;;
"current" )
nvm_version current
;;
"alias" )
mkdir -p $NVM_DIR/alias
if [ $# -le 2 ]; then
for ALIAS in $(nvm_set_nullglob; echo $NVM_DIR/alias/$2* ); do
local DEST
for ALIAS in $NVM_DIR/alias/$2*; do
if [ -e "$ALIAS" ]; then
DEST=`cat $ALIAS`
VERSION=`nvm_version $DEST`
if [ "$DEST" = "$VERSION" ]; then
@@ -447,10 +574,11 @@ nvm() {
else
echo "$(basename $ALIAS) -> $DEST (-> $VERSION)"
fi
fi
done
return
fi
if [ ! "$3" ]; then
if [ -z "$3" ]; then
rm -f $NVM_DIR/alias/$2
echo "$2 -> *poof*"
return
@@ -469,27 +597,35 @@ nvm() {
;;
"unalias" )
mkdir -p $NVM_DIR/alias
[ $# -ne 2 ] && nvm help && return
[ ! -f $NVM_DIR/alias/$2 ] && echo "Alias $2 doesn't exist!" && return
[ $# -ne 2 ] && nvm help && return 127
[ ! -f "$NVM_DIR/alias/$2" ] && echo "Alias $2 doesn't exist!" && return
rm -f $NVM_DIR/alias/$2
echo "Deleted alias $2"
;;
"copy-packages" )
if [ $# -ne 2 ]; then
nvm help
return
return 127
fi
VERSION=`nvm_version $2`
ROOT=`nvm use $VERSION && npm -g root`
INSTALLS=`nvm use $VERSION > /dev/null && npm -g -p ll | \grep "$ROOT\/[^/]\+$" | cut -d '/' -f 8 | cut -d ":" -f 2 | \grep -v npm | tr "\n" " "`
npm install -g $INSTALLS
local ROOT=`(nvm use $VERSION && npm -g root)`
local ROOTDEPTH=$((`echo $ROOT | sed 's/[^\/]//g'|wc -m` -1))
# declare local INSTALLS first, otherwise it doesn't work in zsh
local INSTALLS
INSTALLS=`nvm use $VERSION > /dev/null && npm -g -p ll | \grep "$ROOT\/[^/]\+$" | cut -d '/' -f $(($ROOTDEPTH + 2)) | cut -d ":" -f 2 | \grep -v npm | tr "\n" " "`
npm install -g ${INSTALLS[@]}
;;
"clear-cache" )
rm -f $NVM_DIR/v* 2>/dev/null
echo "Cache cleared."
;;
"version" )
print_versions "`nvm_version $2`"
nvm_version $2
;;
"--version" )
echo "0.7.0"
;;
* )
nvm help
@@ -497,4 +633,5 @@ nvm() {
esac
}
nvm ls default &>/dev/null && nvm use default >/dev/null || true
nvm ls default >/dev/null && nvm use default >/dev/null || true

33
package.json Normal file
View File

@@ -0,0 +1,33 @@
{
"name": "nvm",
"version": "0.7.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"
},
"repository": {
"type": "git",
"url": "git://github.com/creationix/nvm.git"
},
"keywords": [
"nvm",
"node",
"version",
"manager"
],
"author": "Tim Caswell <tim@creationix.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/creationix/nvm/issues"
},
"homepage": "https://github.com/creationix/nvm",
"devDependencies": {
"urchin": "~0.0.2"
}
}

View File

@@ -7,4 +7,6 @@ mkdir ../../../v0.2.3
# The result should contain only the appropriate version numbers.
nvm ls 0.2 | grep v0.2.3 &&
nvm ls 0.1 | grep -v v0.2.3
nvm ls 0.1 | grep -v v0.2.3 &&
nvm ls 0.1 | grep v0.1.3 &&
nvm ls v0.2 | grep v0.2.3

View File

@@ -2,8 +2,12 @@
. ../../../nvm.sh
mkdir ../../../v0.0.{1,3,9}
mkdir ../../../v0.3.{1,3,9}
mkdir ../../../v0.0.1
mkdir ../../../v0.0.3
mkdir ../../../v0.0.9
mkdir ../../../v0.3.1
mkdir ../../../v0.3.3
mkdir ../../../v0.3.9
# The result should contain the version numbers.
nvm ls | grep v0.0.1 &&

View File

@@ -2,4 +2,4 @@
. ../../nvm.sh
nvm alias test v0.1.2
[ $(cat ../../alias/test) = 'v0.1.2' ]
[ "$(cat ../../alias/test)" = "v0.1.2" ]

View File

@@ -0,0 +1,6 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../nvm.sh
[ "$(nvm current)" = "$(node -v)" ] || die "Failed to find current version"

View File

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

View File

@@ -0,0 +1,7 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../nvm.sh
[ "$(nvm install invalid.invalid)" = "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"

View File

@@ -0,0 +1,18 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
TEST_PATH=/usr/bin:/usr/local/bin
NEW_PATH=`nvm_prepend_path "$TEST_PATH" "$NVM_DIR/v0.2.5/bin"`
[ "$NEW_PATH" = "$NVM_DIR/v0.2.5/bin:/usr/bin:/usr/local/bin" ] || die "Not correctly prepended: $STRIPPED_PATH "
EMPTY_PATH=
NEW_PATH=`nvm_prepend_path "$EMPTY_PATH" "$NVM_DIR/v0.2.5/bin"`
[ "$NEW_PATH" = "$NVM_DIR/v0.2.5/bin" ] || die "Not correctly prepended: $STRIPPED_PATH "

View File

@@ -0,0 +1,11 @@
#!/bin/sh
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
STRIPPED_PATH=`nvm_strip_path "$TEST_PATH" "/bin"`
[ "$STRIPPED_PATH" = "/usr/bin:/usr/local/bin" ] || die "Not correctly stripped: $STRIPPED_PATH "

View File

@@ -5,8 +5,9 @@
# Back up
type setopt >/dev/null 2>&1 && setopt NULL_GLOB
type shopt >/dev/null 2>&1 && shopt -s nullglob
mkdir -p bak
mv v* src alias bak || sleep 0s
for SRC in v* src alias; do
[ -e "$SRC" ] && mv "$SRC" bak
done
true
)

View File

@@ -6,7 +6,7 @@
# Restore
if [ -d bak ]
then
mv bak/* . || sleep 0s
mv bak/* . > /dev/null 2>&1 || sleep 0s
rmdir bak
fi
mkdir -p src alias

View File

@@ -1,14 +0,0 @@
#!/bin/sh
set -e
. ../../nvm.sh
# Remove the stuff we're clobbering.
[ -e ../../v0.6.14 ] && rm -R ../../v0.6.14
# Install
nvm install 0.6.14
# Check
[ -d ../../v0.6.14 ]
nvm run v0.6.14 --version | grep v0.6.14

View File

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

View File

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

View File

@@ -0,0 +1,24 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
[ "$(nvm install invalid.invalid)" = "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
# Install from binary
nvm install 0.9.7
nvm install 0.9.12
nvm use 0.9.7
node --version | grep v0.9.7 || die "precondition failed: node doesn't start at 0.9.7"
nvm install 0.9.12
node --version | grep v0.9.12 || die "nvm install on already installed version doesn't use it"

View File

@@ -0,0 +1,17 @@
#!/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

@@ -0,0 +1,17 @@
#!/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

@@ -0,0 +1,24 @@
#!/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 install 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

@@ -0,0 +1,20 @@
#!/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
cat "$NVM_TEST_VERSION" > .nvmrc
nvm install
# Check
[ -d ../../../$NVM_TEST_VERSION ]
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION

View File

@@ -0,0 +1,20 @@
#!/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
cat "$NVM_TEST_VERSION" > .nvmrc
nvm install -s
# Check
[ -d ../../../$NVM_TEST_VERSION ]
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION

View File

@@ -0,0 +1,6 @@
#!/bin/sh
if [ -f ".nvmrc" ]; then
mv .nvmrc .nvmrc.bak
fi

View File

@@ -0,0 +1,13 @@
#!/bin/sh
. ../../../nvm.sh
nvm uninstall v0.10.7
if [ -f ".nvmrc" ]; then
rm .nvmrc
fi
if [ -f ".nvmrc.bak" ]; then
mv .nvmrc.bak .nvmrc
fi

View File

@@ -0,0 +1,9 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
[ "$(nvm run 0.10.7 --version | tail -1)" = "v0.10.7" ] || die "`nvm run` failed to run with the correct version"

View File

@@ -0,0 +1,13 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
echo "0.10.7" > .nvmrc
[ "$(nvm run --version | tail -1)" = "v0.10.7" ] || die "\`nvm run\` failed to run with the .nvmrc version"
[ "$(nvm run --version | head -1)" = "Found '$PWD/.nvmrc' with version <0.10.7>" ] || die "\`nvm run\` failed to print out the \"found in .nvmrc\" message"

9
test/slow/nvm run/setup_dir Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/sh
. ../../../nvm.sh
nvm install 0.10.7
if [ -f ".nvmrc" ]; then
mv .nvmrc .nvmrc.bak
fi

11
test/slow/nvm run/teardown_dir Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/sh
. ../../../nvm.sh
nvm uninstall v0.10.7
rm .nvmrc
if [ -f ".nvmrc.bak" ]; then
mv .nvmrc.bak .nvmrc
fi