Compare commits

...

424 Commits

Author SHA1 Message Date
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
Jordan Harband
5686d9a3bb Addressing comments raised in #171 2013-11-29 14:26:12 -06:00
Jordan Harband
49e9a309c3 Merge pull request #305 from marioidival/patch-1
For zsh users
2013-11-13 11:02:56 -08:00
Jordan Harband
788d87774f Merge pull request #312 from quiqueg/master
Fixed bash error caused by lack of double quotes
2013-10-25 09:32:59 -07:00
Jordan Harband
7ccc2dd5ed Merge pull request #311 from loganfsmyth/remove-tar
Properly remove the tar file.
2013-10-24 22:52:18 -07:00
Logan Smyth
7862182d6f Add -f 2013-10-24 20:09:33 -07:00
Matthew Alexander
b4a9c14d4e Fixed bash error caused by lack of double quotes 2013-10-24 18:59:37 -07:00
Logan Smyth
473dd86f48 Properly remove the tar file. 2013-10-23 22:14:02 -07:00
Mario Idival
6e1c249ecd For zsh users
i use zsh and i did this update in install.sh local, is good for you too :)
2013-10-10 14:30:53 -03: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
Jordan Harband
d3f04c793e Merge pull request #296 from frasertweedale/fix/generic-source
install.sh: use a more generic SOURCE_STR
2013-09-23 20:37:08 -07:00
Fraser Tweedale
ef7e3cc39a install.sh: use a more generic SOURCE_STR
SOURCE_STR currently includes the value of $HOME (at install time).
Change SOURCE_STR to include a literal "$HOME" (to be expanded at
profile runtime) so that sourcing nvm will work if the user changes
their username, shares their profile, et cetera.

Also use the more portable single-square-bracket test.
2013-09-22 14:58:19 +10:00
Jordan Harband
e6116d96ab Mentioning install-gitless.sh in the "no git" error message - finishing off #246. 2013-09-21 12:58:01 -07:00
Jordan Harband
5e2ad5bb8d Merge pull request #246 from ddryden/master
Add check for git in the installer script.
2013-09-21 12:55:55 -07:00
Jordan Harband
a7a91441aa Merge pull request #294 from 00Davo/patch-1
Finds NVM_DIR with `cd -q` on zsh
2013-09-18 10:14:44 -07:00
00Davo
a2a8ddb779 Use only shell builtins to avoid triggering autojump, instead of needing GNU readlink
Under Zsh, the `-q` flag to `cd` makes it not run `chpwd` hooks and hence makes it not add `~/.nvm` to `autojump`.
2013-09-19 02:50:20 +10:00
00Davo
1ad9d18257 Finds NVM_DIR without using cd
Using `cd` makes the nvm directory the number-one directory in `autojump`'s database---which is somewhat confusing since the user basically never `cd`s to it directly!---so here's an alternative method that doesn't use the `cd` command. I've checked it works in both Bash and Zsh.
2013-09-18 17:10:24 +10:00
Jordan Harband
e58c495f69 Merge pull request #293 from lloydde/patch-1
updt urchin lnk, urchin.sh domain pending delete
2013-09-16 22:31:48 -07:00
Lloyd Dewolf
676a2cc865 updt urchin lnk, urchin.sh domain pending delete
$ curl -i www.urchin.sh
curl: (6) Could not resolve host: www.urchin.sh; nodename nor servname provided, or not known

http://www.nic.sh/cgi-bin/whois
"Domain pendingDelete - expired 2013-07-12, unless it is renewed it will be deleted at or after 00:10 GMT 90 days beyond the expiry date."
2013-09-16 22:17:33 -07:00
Jordan Harband
c6f72953c9 Merge pull request #292 from martiniwanowski/master
Fix for issue #196, deconfusified the scenario
2013-09-10 13:28:11 -07:00
Martin Iwanowski
41352e866d Fix for issue #196, deconfusified the scenario 2013-09-10 12:34:32 +02:00
Dennis Dryden
34a067647c Add check for git to install script. 2013-09-09 14:35:30 +01:00
Tim Caswell
db3035c29b Merge pull request #289 from martiniwanowski/master
Fixed typo.
2013-08-31 11:20:51 -07:00
Martin Iwanowski
01f8eef7a2 Fixed typo. 2013-08-31 19:55:12 +02:00
Jordan Harband
e6d1d0c4de Merge pull request #283 from ljharb/add_license
Add license
2013-08-20 10:41:30 -07:00
Jordan Harband
d6fe38a356 Add LICENSE file. Closes #122. 2013-08-20 10:41:05 -07:00
Jordan Harband
1478c72124 Lowercasing nvm like npm. 2013-08-20 10:39:44 -07:00
Jordan Harband
8e8da23711 Merge pull request #282 from interarticle/master
Fixed curl silently ignoring 302 redirections. Fixes #281
2013-08-20 10:24:15 -07:00
Max Zhao
62dec72394 Fixed curl silently ignoring 302 redirections
Under certain network environments, due to poor implementation of file
download caches (immoral Chinese ISP), the direct download of Node.js
packages (http://nodejs.org/dist/node-$VERSION.tar.gz) will be
redirected to alternative urls using 302 redirections, which are not
handled by `curl --process-bar` by default. Instead, curl will "fail"
silently without creating any output file or error exitcode.
(Tested under Ubuntu 12.04 Desktop)

Fixed by adding "-L" switches to the curl commands responsible for
downloading the binary and source node.js packages.
2013-08-21 00:27:10 +08:00
Jordan Harband
c2e4e1a8a7 Merge pull request #280 from activars/master
added documentation for .nvmrc usage
2013-08-15 11:58:34 -07:00
Jing Dong
6a98d168b7 added documentation for .nvmrc usage 2013-08-15 19:25:51 +01:00
Tim Caswell
8ce8bef249 Merge pull request #276 from frasertweedale/fix/readme-clone-url
readme: use https clone url
2013-08-09 17:13:55 -07:00
Fraser Tweedale
2b216ab5d1 readme: show https clone url
The git:// transport is vulnerable to man-in-the-middle and DNS
spoofing attacks and its use over untrusted networks should be
discouraged.

Change to the https:// clone url in the install instructions.
2013-08-10 10:04:25 +10:00
Jordan Harband
af105894d7 Merge pull request #274 from evocateur/patch-1
Avoid error from aliased `which` during install
2013-07-31 13:55:15 -07:00
Daniel Stockman
e5d7d493b9 Avoid error from aliased which during install
The same fix as #207, just for fools like me who have `which` aliased to `type` in OS X. Without this escape, a very cryptic error message is emitted (though the install ultimately succeeds, as long as one actually has `curl` installed).
2013-07-31 12:42:19 -07:00
Jordan Harband
e0bd3735f1 Merge pull request #272 from amv/master
better guides for missing profile
2013-07-26 11:04:45 -07:00
Antti Vähäkotamäki
81d731d355 better guides for missing profile 2013-07-26 14:58:47 +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
Jordan Harband
7fb6d1ec6a Merge pull request #259 from jsatt/master
Handle cases where grep is aliased to change output
2013-06-26 14:52:07 -07:00
Jeremy Satterfield
6690aecc6c fix handle cases of grep aliases as described in to resolve #207 2013-06-26 15:55:39 -05:00
Tim Caswell
137539cf48 Merge pull request #258 from codewhale/master
add support for Raspberry Pi binaries
2013-06-24 06:40:31 -07:00
Code Whale
4a7945f8c1 support Raspberry Pi binaries 2013-06-24 13:33:19 +00:00
Jordan Harband
8b9c0b933c Merge pull request #256 from cliffano/master
Add sh directive and replace bash function with sh function.
2013-06-22 09:57:20 -07:00
Tim Caswell
8983644854 Merge pull request #254 from stelcheck/gitless
Gitless in Seattle
2013-06-22 07:50:05 -07:00
Cliffano Subagio
39c5d0597d Fix style, opening curly brace on the same line as function declaration. 2013-06-22 23:11:43 +10:00
Cliffano Subagio
ab71d50b3a Add sh directive and replace bash function with sh function. 2013-06-21 17:56:58 +10:00
Jordan Harband
36ce8f0010 Merge pull request #253 from ljharb/update_readme
Using source instead of dot. Closes #211.
2013-06-14 09:27:44 -07:00
Jordan Harband
c6cb1601f7 Using source instead of dot. 2013-06-14 09:26:51 -07:00
Jordan Harband
be0b2926b3 Merge pull request #252 from ljharb/fix_readme
Fix readme
2013-06-14 09:16:14 -07:00
Jordan Harband
f8a6e23fa7 Updating copyright year 2013-06-14 09:14:52 -07:00
Jordan Harband
1e353b2773 Updating 0.8 references to 0.10 2013-06-14 09:14:37 -07:00
Jordan Harband
9537db1a4a Updating ~/nvm to ~/.nvm 2013-06-14 09:13:54 -07:00
Jordan Harband
e7e84ec376 Merge pull request #219 from techdives/patch-1
Update README.markdown
2013-06-14 09:12:26 -07:00
Jordan Harband
6a2d92bc51 Merge pull request #238 from shibukawa/patch-1
Update README.markdown
2013-06-14 09:11:27 -07:00
Tim Caswell
855d89bef0 Merge pull request #251 from stelcheck/NVM_DIR
* NVM_TARGET renamed to NVM_DIR
2013-06-14 06:01:23 -07:00
Tim Caswell
36843d97cb Merge pull request #250 from ronkorving/gitless
Git-less installation script
2013-06-14 05:56:30 -07:00
stelcheck
c5437bb222 * NVM_TARGET renamed to NVM_DIR (this will ensure that any locally
* existing nvm copy will be picked up and updated)
2013-06-14 16:20:36 +09:00
stelcheck
d428bcd50e * TARGET was not converted to DIR 2013-06-14 16:17:24 +09:00
stelcheck
f82cde11a9 * Using raw.github.com instead, downloading only nvm.sh
* tar no longer required
2013-06-14 16:15:54 +09:00
Ron Korving
dc46a740a3 Fix newline issue in install.sh 2013-06-14 15:10:59 +09:00
Ron Korving
93e84a2676 Moved gitless installer into its own file. 2013-06-14 13:13:33 +09:00
Ron Korving
5a4c097aac Install script no longer depends on git to be installed.
Also fixed a bug where a literal "\n" would be injected into the bash profile.
2013-06-14 13:00:52 +09:00
Tim Caswell
5c6af59fcd Merge pull request #236 from donovanjamesking/master
Fixes issue 232 and "nvm ls" returning "N/A" when it shouldn't
2013-06-10 06:36:16 -07:00
Tim Caswell
72fd8c970a Merge pull request #229 from em-/testsuite-fixes
Testsuite fixes
2013-06-10 06:34:35 -07:00
Derek Keller
d1d53ea979 Updated fix for issues #232 and #244
Fixes issues #232 and #244 where "nvm ls" returns inconsistent results depending on the number of node versions installed.  This updated fix uses the find and sort commands only.  Tested in bash v3.2.48 and v4.2.25, and zsh v4.3.11.
2013-06-09 21:44:46 -05:00
Emanuele Aina
04dba10b9a Fix the setup/teardown urchin test scripts under zsh
The v* glob expansions were failing with an error under zsh, just set
nullglob/NULL_GLOB and make both bash and zsh happier.
2013-06-07 23:18:50 +02:00
Emanuele Aina
8486a0da2b Fix the 'nvm deactivate' test
`nvm deactivate` does not really remove the nvm command, it just remove
the entries from $PATH and $MANPATH previously adde with `nvm use`.
2013-06-07 23:18:50 +02:00
Tim Caswell
b2b29ff5c5 Merge pull request #243 from lgw4/master
Changed git download protocol from git:// to https:// to work around firewalls.
2013-06-03 18:57:57 -07:00
Chip Warden
6c57b275db Changed git protocol from git:// to https:// to work around firewalls. 2013-06-03 17:05:30 -05:00
Tim Caswell
7cc6f37e69 Merge pull request #242 from koenpunt/patch-1
Return 1 so exit status is not null on error
2013-06-03 14:18:03 -07:00
Koen Punt
0f05655ee6 Return 1 so exit status is not null on error 2013-06-03 22:26:52 +03:00
Tim Caswell
6b932e59c3 Remove column since many common environments don't have it. 2013-06-03 10:08:13 -04:00
Yoshiki Shibukawa
9a8e66cfca Update README.markdown 2013-05-15 11:41:30 -07:00
Tim Caswell
66633de1a9 Merge pull request #235 from okuryu/fix-install
Remove `-e` option in `install.sh` script
2013-05-13 13:01:37 -07:00
Donovan James King
bc04ed3ece Fixes issue 232
Fixes issue 232 that occurs in at least bash v4.2.25 where "nvm ls" returns "N/A" no matter how many versions of node have been installed.  The fix uses a combination of the find, tr and basename commands instead of basename only.  Tested in bash v3.2.48 and v4.2.25 and zsh v4.3.11.
2013-05-13 14:35:36 -05:00
Ryuichi Okumura
9205ff8001 Remove -e option in install.sh script
The `sh` actually doesn't support `-e` option.
2013-05-14 00:05:53 +09:00
Tim Caswell
367ae728fb Merge pull request #231 from miguelcoba/patch-1
Drop invalid -a flag for basename.
2013-05-09 15:02:22 -07:00
Miguel Cobá
335456d008 Drop invalid -a flag for basename.
basename doesn't accept options in bash. This causes the VERSIONS variable get the 'N/A' value for $ nvm ls command.

From basename man page:
NAME
       basename - strip directory and suffix from filenames

SYNOPSIS
       basename NAME [SUFFIX]
       basename OPTION

DESCRIPTION
       Print NAME with any leading directory components removed.  If specified, also remove a trailing SUFFIX.

       --help display this help and exit

       --version
              output version information and exit



coreutils version used in Linux Mint 14 Nadia.

GNU coreutils 8.12.197-032bb                                               September 2011                                                               BASENAME(1)

No idea if this flag exists on FreeBSD or other unixes (if they use gnu coreutils shouldn't be any problem)
2013-05-09 13:50:12 -04:00
Tim Caswell
eade411422 Merge pull request #198 from ArtemGordinsky/master
Adding a newline before the source string in the ".bash_profile"
2013-05-09 06:39:01 -07:00
Tim Caswell
cca6edfc5c Merge pull request #203 from em-/master
Don't trust the environment and explicitly ask for the builtin `cd'
2013-05-06 20:36:11 -07:00
Emanuele Aina
42915fc21c Reduce usage of `cd' to avoid issues with shell aliases
Since we run in interactive context the builtin `cd' may have been aliased to
print some additional info when invoked, thus it's safer for us to avoid
parsing the output from subshells which calls it.

For instance in .bash_profile I have the following function to redefine
`cd' such that it will list the destination directory contents:
cd () { builtin cd "$@" && ls -F --color=auto }
2013-05-03 17:44:02 +01:00
Emanuele Aina
f1b484ee87 Silence stderr warning on `nvm uninstall' with no configured alias 2013-05-03 17:42:14 +01:00
Tim Caswell
6c3708d337 Merge pull request #195 from gpad/patch-1
Resolved Issue #194
2013-04-24 09:03:36 -07:00
Tim Caswell
91a7aa8611 Merge pull request #222 from jnlin/master
Added FreeBSD support
2013-04-24 09:02:12 -07:00
jnlin
db7494494c Add FreeBSD support 2013-04-24 15:42:10 +08:00
techdives
ca44bafff2 Update README.markdown
I do think recent changes changed nvm to .nvm.
2013-04-16 17:40:59 -07:00
Tim Caswell
01189e144c Merge pull request #200 from croach/issue-199
Fixes Issue 199
2013-03-07 15:02:22 -08:00
Tim Caswell
3fe12f0a49 Merge pull request #202 from hugojosefson/recommend-version-0.8
Recommend version 0.8 in README.markdown.
2013-03-04 06:54:23 -08:00
Hugo Josefson
e4acd63991 Clarify difference between nvm ls and nvm ls-remote. 2013-03-04 12:54:42 +01:00
Hugo Josefson
3ce23aa726 Recommend version 0.8 in README.markdown.
Automatically install the latest available 0.8.x version.
2013-03-04 12:50:55 +01:00
Christopher Roach
205117bed4 Fixes issue 199
Fixes issue 199 where the bash completion was not working in ZSH
because the builtin bash command `complete` was not found. The fix
executes the `bashcompinit` command which creates the `complete`
function for the Z shell.
2013-03-01 10:55:58 -08:00
Artem
9c7da6cec3 Adding a newline before the source string in the ".bash_profile"
Resolved Issue #197
2013-02-27 11:50:08 +02:00
Artem
1088b4b00f Ignoring the ".DS_Store" files on OS X 2013-02-27 11:43:05 +02:00
GPad
5811cb9e73 Resolved Issue #194
Issue #194
2013-02-11 19:23:25 +01:00
Tim Caswell
0ec339e040 Merge pull request #192 from gpad/nvmrc
Use .nvmrc if present
2013-01-25 11:50:11 -08:00
GPad
7226e5fb98 read the .nvmrc if present 2013-01-25 19:13:40 +01:00
GPad
bc9c82cb9f read version from .nvmrc if not specified 2013-01-22 13:28:13 +01:00
Tim Caswell
f605581c7d return not exit 2013-01-21 12:07:54 -06:00
Tim Caswell
87a76af398 Merge pull request #191 from koenpunt/patch-1
Add exit code, fix #190
2013-01-21 08:51:14 -08:00
Koen Punt
70e1b81ad3 Add exit code, fix #190 2013-01-21 17:26:16 +01:00
Tim Caswell
e145978e73 Merge pull request #189 from kt3k/feature/hyphen-s-option-2
Add -s option to force install from source
2013-01-14 05:59:47 -08:00
Yosiya Hinosawa
a6be969403 changed shasums file url because in v0.8.6 .txt.asc file is not available. 2013-01-13 16:13:20 +09:00
Yosiya Hinosawa
184f641730 fixed the condition for the binary package availability. 2013-01-13 16:10:50 +09:00
Yoshiya Hinosawa
7dc0827eaa minor modifications. 2013-01-12 14:43:04 +09:00
Yoshiya Hinosawa
278fd031b0 added test for installation with -s option. 2013-01-12 14:42:41 +09:00
Yoshiya Hinosawa
7013372867 added -s (install from source) option. 2013-01-12 14:42:28 +09:00
Yosiya Hinosawa
881178db01 fixed syntax error. 2013-01-12 14:42:13 +09:00
Yoshiya Hinosawa
1845a4a5a9 added the description about -s option. 2013-01-12 14:40:41 +09:00
Tim Caswell
bc508802e5 Update README.markdown 2012-12-12 09:48:26 -06:00
Tim Caswell
0a4d3a2944 Merge pull request #181 from andrwj/master
fixed 'bash command not found sha1sum' in Mac OS
2012-12-08 12:59:52 -08:00
A.J
5596054445 fixed wrong condition checking for 'shasum' (I'm using Mac OS 10.8.2)
line 188, `which shasum > /dev/null 2>&1` will be replaced by:

	'/usr/bin/shasum > /dev/null 2>&1'

but, `/usr/bin/shasum` needs filename argument which is ommited and the
test results always 'false'.
2012-12-09 05:17:13 +09:00
Tim Caswell
68f7dc9cb3 Merge pull request #171 from cou929/support_sha1sum_command
support platforms which does not have shasum command
2012-12-04 17:46:04 -08:00
Tim Caswell
9c3af112ca Merge pull request #175 from Marsup/fix-172
Fix #172 on ZSH
2012-12-04 17:45:25 -08:00
Tim Caswell
eaf8a50483 Merge pull request #178 from koenpunt/patch-2
Fixed variable expansion for `SOURCE_STR`
2012-12-04 15:32:55 -08:00
Tim Caswell
6c70627478 Merge pull request #177 from koenpunt/patch-1
Added instructions for the install script
2012-12-04 15:32:30 -08:00
Koen Punt
dc2bf8c526 Fixed variable expansion for SOURCE_STR 2012-12-04 23:26:49 +01:00
Koen Punt
b063b32642 Added instructions for the install script 2012-12-04 23:21:00 +01:00
Tim Caswell
7bee39fd81 Merge pull request #176 from witoldsz/patch-1
Update install.sh
2012-12-04 13:34:29 -08:00
Witold Szczerba
2f6b0ca9d7 Update install.sh
$HOME/.nvm used instead of introduced earlier NVM_TARGET.
2012-12-04 21:36:12 +01:00
Marsup
2662840064 Fix #172 on ZSH 2012-11-27 23:46:04 +01:00
Kosei Moriyama
1a08edd94e support platforms which does not have shasum command
use sha1sum command if there is no shasum command
2012-11-24 00:08:49 +09:00
Tim Caswell
59c8eda18c Merge pull request #170 from tisba/master
Avoid pollution of environment
2012-11-20 06:50:29 -08:00
Sebastian Cohnen
0803e317e1 avoid environment pollution with NVM internals 2012-11-20 15:32:59 +01:00
Tim Caswell
1709fa9248 Merge pull request #165 from koenpunt/install
Basic install file
2012-10-30 09:26:24 -07:00
Koen Punt
3c4bf80ec7 added basic install file 2012-10-30 00:04:52 +01:00
Tim Caswell
dd3650fc8f Merge pull request #164 from paulownia/fix_for_v0.4
Cannot install v0.4
2012-10-27 20:28:41 -07:00
hisanori
4ffd4bb34f fix installation problem about v0.4 2012-10-27 04:09:10 +09:00
Tim Caswell
d6ef9c8893 Merge pull request #163 from wlaurance/master
Glob i*86
2012-10-26 07:53:02 -07:00
wlaurance
21f00362b0 Account for x86 architectures 2012-10-25 15:39:08 -04:00
Tim Caswell
f3bf583285 Merge pull request #161 from wlaurance/master
Checksum checking
2012-10-23 12:25:13 -07:00
wlaurance
a1d14ea5b8 Checksum support for binary downloads
Checksum support for source downloads

Closes #159
2012-10-23 14:26:21 -04:00
Tim Caswell
3b2d2e4b61 Merge pull request #160 from wlaurance/master
i686 architecture
2012-10-23 09:36:42 -07:00
wlaurance
03b16d7a67 Account for uname -a i686 2012-10-23 12:19:42 -04:00
Tim Caswell
e1ec264b26 Merge pull request #155 from jwietelmann/master
NVM downloading x86 binaries instead of source for ARM Linux box
2012-10-18 14:42:55 -07:00
Joel Wietelmann
182e28f1ae Making ARM stop downloading x86 binaries 2012-10-18 21:19:08 +00:00
Tim Caswell
5977a02e8b Merge pull request #154 from mikedeboer/master
one more: list-remote
2012-10-17 09:54:14 -07:00
mikedeboer
ab16d34012 Merge remote-tracking branch 'upstream/master'
Conflicts:
	bash_completion
2012-10-17 18:51:53 +02:00
mikedeboer
c4a13dd2b6 updated list of commands 2012-10-17 16:50:05 +00:00
Tim Caswell
7c2dfda88d Add ls-remote to autocomplete 2012-10-17 16:47:24 +00:00
Tim Caswell
1dbb7c799d Update README.markdown 2012-10-17 11:45:43 -05:00
Tim Caswell
d9f25f8f58 Merge pull request #96 from caio/dont-fail-on-source
Avoid carrying over test status when no node version is installed
2012-10-17 09:41:43 -07:00
Tim Caswell
b73f0930cc Merge pull request #106 from ghost/master
nodejs.org doesnt seem to support resuming partial downloads
2012-10-17 09:40:27 -07:00
Tim Caswell
3766bff734 Merge pull request #148 from nathan-lafreniere/master
Fixes ls-remote with no parameters in linux
2012-10-17 07:27:28 -07:00
Tim Caswell
304924a969 Merge pull request #152 from Marsup/binary-installs
Support binary installs
2012-10-12 08:25:57 -07:00
Marsup
a0c4229abe Support binary installs
Heavily inspired by isaacs/nave
2012-10-12 09:39:35 +02:00
Tim Caswell
eea0b05ece Merge pull request #150 from tlevine/master
I added tests.
2012-10-11 13:52:44 -07:00
Thomas Levine
a27d39139b tests from readme
fast tests

alias

unalias

more alias tests

tests

document testing

warn not to run while testing

chmod +x deactivate

specify the version (commit) of urchin

installation test

run

tests for ls

switch unsetopt to the thing creationix has

rename tests

urchin log

adjust urchin version
2012-10-11 16:12:50 -04:00
Thomas Levine
903479aeca Merge branch 'master' of github.com:tlevine/nvm
Conflicts:
	nvm.sh
2012-10-10 19:06:34 -04:00
Tim Caswell
d8713bb2e8 Merge pull request #149 from koenpunt/zsh-compat
Made string comparison also compatible for zsh
2012-10-09 08:11:54 -07:00
Koen Punt
4a6c696074 Made string comparison also compatible for zsh 2012-10-09 13:36:44 +02:00
Nathan LaFreniere
a368227237 make ls-remote work with no parameters in linux 2012-10-07 17:19:53 -07:00
Tim Caswell
5a17b81a09 Merge pull request #146 from nathan-lafreniere/master
fixup prepending of the v in ls-remote
2012-10-05 21:13:29 -07:00
Nathan LaFreniere
e1be38f90d fixup automatically prepending the v for remote requests 2012-10-05 11:39:38 -07:00
Tim Caswell
80cf1159bb Merge pull request #145 from nathan-lafreniere/master
added ls-remote command
2012-10-05 08:05:04 -07:00
Nathan LaFreniere
9fb65cbf7b add v back to ls-remote results 2012-10-04 11:10:31 -07:00
Nathan LaFreniere
693abf3173 make install use a different nvm_version to make not specifying the v avoid clobbering aliases 2012-10-04 10:32:36 -07:00
Nathan LaFreniere
e755c47d5a made ls-remote actually usable 2012-10-04 09:41:32 -07:00
Nathan LaFreniere
3d65d55b5a install requested version automatically if it isnt available 2012-10-04 09:40:00 -07:00
Nathan LaFreniere
6505c98461 add ls-remote 2012-10-04 09:38:51 -07:00
Nathan LaFreniere
5af8cec6dc updated readme 2012-10-04 09:37:12 -07:00
Nathan LaFreniere
ebff66649e add v to version if user does not specify it to simplify commands 2012-10-04 09:36:39 -07:00
Nathan LaFreniere
07aaa91c9b Revert "add /.nvm to NVM_DIR so we dont clutter up home directories"
This reverts commit a107b12d2a.
2012-10-04 09:29:05 -07:00
Nathan LaFreniere
a107b12d2a add /.nvm to NVM_DIR so we dont clutter up home directories 2012-10-04 09:28:32 -07:00
Tim Caswell
a12b6d7dd6 Merge pull request #144 from logosity/master
fix for npm install failure (corrects: Issue #91)
2012-10-03 19:07:48 -07:00
Bill Caputo
2adbe8bd7f changed npm url to use https (script has moved) 2012-10-03 16:24:43 -05:00
Tim Caswell
04652a5090 Merge pull request #133 from mimetnet/master
Fix warning when unsetopt isn't found
2012-08-22 11:32:49 -07:00
Matthew Metnetsky
d68c38902a Fix warning when unsetopt isn't found 2012-08-22 14:19:18 -04:00
Tim Caswell
cd14416bfd Merge pull request #131 from rummik/patch-1
Fix parse error in Zsh 4.3.17
2012-08-22 08:45:47 -07:00
Thomas Levine
9190297d5e Hide errors from which unsetopt
Errors occurred when it was run in bash.
2012-08-22 09:49:48 -04:00
rummik
ad5242ea0b Fix parse error in Zsh 4.3.17 2012-08-20 18:02:38 -03:00
Tim Caswell
5132a1eb6f Merge pull request #129 from indianburger/master
Add check for unsetopt issue #128
2012-08-20 08:28:20 -07:00
Aravind Ramanathan
3bb2634d2f Added check for unsetopt
unsetopt doesn't exist on OSX by default which causes `. nvm.sh` to
fail at that line.
2012-08-07 23:22:27 -07:00
Tim Caswell
e475d7e7ab Fix bug introduced by pull # 125 2012-08-01 12:48:41 -05:00
Tim Caswell
cf00a067ca Merge pull request #125 from fatshotty/master
possibility to pass argument to node while compiling
2012-08-01 08:40:21 -07:00
fatshotty
f8c1822033 added additional options for compiling node 2012-08-01 11:10:25 +02:00
Tim Caswell
7d4b12446a Add explicit MIT license to README 2012-07-20 08:30:13 -05:00
Tim Caswell
96a4488732 Merge pull request #120 from tomassedovic/issue-39-fix-zsh-error-msg
Supress ZSH "no matches found" error
2012-07-09 07:34:03 -07:00
Tomas Sedovic
3dd6b29905 Supress ZSH "no matches found" error
Fixes issue #39

ZSH's default globbing behaviour differs from Bash. If there is no
match, ZSH itself will print the error message.

This means that piping a commantd's STDERR to /dev/null will not
hide it.

By unsetting the NOMATCH option we get a behaviour similar to Bash.

Signed-off-by: Tomas Sedovic <tomas@sedovic.cz>
2012-07-07 14:37:09 +02:00
Tim Caswell
91670abdca Merge pull request #118 from gosquared/set-friendly
Set friendly
2012-07-05 09:26:03 -07:00
Gerhard Lazu
d544d8e2eb If you're using set -e (and why wouldn't you), this halts all execution 2012-07-03 10:41:15 +01:00
Gerhard Lazu
3e62657575 If cd fails, don't run pwd
Whitespace...
2012-07-03 10:36:23 +01:00
Tim Caswell
c371a3a26b Merge pull request #109 from rafmagana/bash_completion
Bash completion
2012-04-09 10:26:37 -07:00
Rafael Magana
cfa81b49d1 bash completion 2012-04-09 01:25:49 -05:00
Tim Caswell
6e50bc0d78 Update README.markdown 2012-04-06 10:49:48 -05:00
Tim Caswell
6d58fcb8c0 Update README.markdown 2012-03-24 09:03:23 -05:00
Tim Caswell
5eb95fd641 Update README.markdown 2012-03-24 09:02:03 -05:00
Tim Caswell
cd7c58ff6a Update README.markdown 2012-03-23 15:04:45 -05:00
Wtfcoder
a86262520a remove continue from curl arg. nodejs.org doesnt seems to support continue, CDN effect perhaps? 2012-03-13 11:51:05 +07:00
Tim Caswell
60892c7b51 Merge pull request #105 from elf-pavlik/master
added note to README with solution to problem with version of python on some systems
2012-03-06 18:33:07 -08:00
elf Pavlik
0dd0224f2d added note about solution to problem with version of python on systems like Arch Linux 2012-03-07 01:34:12 +01:00
Tim Caswell
dcd29296e9 Merge pull request #104 from prozacgod/master
NVM "need curl to proceed"
2012-02-27 10:47:29 -08:00
David Hagler
45051f4d43 changed the function to place the curl requirement where it belongs 2012-02-24 11:25:27 -06:00
David Hagler
7c3af21ebe Removed default check for curl, and placed it into nvm function
This fixes issue with curl not being installed before nvm is initially sourced
and then curl subsequently being installed.

removed creation of global curl function (after error detected) which
overwrites the system tool, preventing execution of later installed
curl binary
2012-02-24 10:52:25 -06:00
Tim Caswell
293061b8b7 Merge pull request #102 from chakrit/patch-1
`nvm version` and `nvm ls` not correctly reporting current version.
2012-02-20 07:28:34 -08:00
Chakrit Wichian
a49f77135a nvm version and nvm ls not correctly reporting current version on both zsh and bash. 2012-02-19 18:12:14 +07:00
Tim Caswell
1eaf6e2db7 Merge pull request #65 from symposion/master
Fix for incorrect version sorting
2012-02-06 07:49:16 -08:00
Lucian Holland
b2683fdb11 Merge remote-tracking branch 'upstream/master' 2012-01-27 10:38:41 +00:00
Caio Romão
53cfd2dd9b Avoid carrying over test status when no node version is installed
When sourcing nvm.sh, if there are no version of node installed the command
`nvm ls default` silentry fails, however it's return status code (`$?`) is
still set to non-zero, which means an error.

This patch simply avoids this issue by making sure the status code after
sourcing is ok so that people that put the returned status codes in their
command line prompt don't get an error every time `nvm.sh` is sourced.
2012-01-18 17:43:28 -02:00
Tim Caswell
ec2327fddd Merge pull request #83 from jeffv/master
Fixes npm install to check version before running
2011-11-17 16:07:14 -08:00
Jeffrey D. Van Alstine
18f4064003 Fixes npm version check for node v0.2.0, v0.2.1 and v0.2.2 2011-11-17 16:15:31 -07:00
Jeffrey D. Van Alstine
990ad81419 Check if node v0.1.x or v0.2.x before npm installs 2011-11-17 15:38:51 -07:00
Tim Caswell
d7cdabe8e2 Merge pull request #82 from mmalecki/run-help
[doc] Update help
2011-11-14 10:37:49 -08:00
Maciej Małecki
269bb008fc [doc] Update help 2011-11-14 19:35:55 +01:00
Tim Caswell
a987f8e67d Merge pull request #76 from mmalecki/run
[feature] Run command
2011-11-14 08:30:06 -08:00
Tim Caswell
0aa40a9c21 Merge pull request #81 from alessioalex/master
alias node for sudoers in documentation
2011-11-14 07:45:22 -08:00
alessioalex
629b51ebf1 alias node for sudoers in documentation 2011-11-14 16:16:09 +02:00
Tim Caswell
39dbc65104 Merge pull request #80 from alessioalex/master
Delete partials from /src [as we talked on IRC]
2011-11-14 05:54:43 -08:00
alessioalex
0700d14065 Remove downloads from /src if installation failed 2011-11-14 15:48:56 +02:00
Maciej Małecki
53e1764a8a [feature] Allow passing additional arguments to node
For example:

    nvm run v0.6.0 myApp.js
2011-11-05 17:32:17 +01:00
Lucian Holland
fda6e7f8de Rewrote version listing system
Now sorts correctly in all instances and prints highlights
even in sorted views. Also will output a list of matching versions
for commands of the form nvm ls 0.4* rather than just printing one
version. nvm version 0.4 still prints the single latest matching
version, however.
2011-11-04 20:38:16 +00:00
Lucian Holland
6f994715d6 Fixed incorrect sorting of versions 2011-11-04 20:38:15 +00:00
Tim Caswell
8dad534464 Remove broken wget emulation 2011-11-03 16:19:26 -05:00
Maciej Małecki
335a253323 [docs] Document run command 2011-10-29 10:08:13 +02:00
Maciej Małecki
09483f422e [feature] Add run command
`run` command runs given node version without modyfing global state:

    [maciej@PC07 nvm (run)]$ node --version
    v0.4.12
    [maciej@PC07 nvm (run)]$ nvm run 0.4.12
    Running node v0.4.12
    > process.version
    'v0.4.12'
    > [maciej@PC07 nvm (run)]$ nvm run 0.5.9
    Running node v0.5.9
    > process.version
    'v0.5.9'
    > [maciej@PC07 nvm (run)]$ node --version
    v0.4.12
2011-10-29 10:08:05 +02:00
Tim Caswell
4692f496da Merge pull request #71 from bronson/master
trivial: remove references to stable and latest
2011-10-05 14:48:21 -07:00
Scott Bronson
26b07fbdff remove references to stable and latest 2011-10-05 12:47:57 -07:00
Scott Bronson
656549dd44 make "list" a synonym for "ls" 2011-10-05 12:43:50 -07:00
Tim Caswell
ff3e7d4025 Merge pull request #70 from mdiniz/master
Fix wrong full version matching
2011-10-01 16:37:41 -07:00
Marcelo Diniz
f939adbedb Fix wrong full version matching 2011-10-02 00:59:20 +02:00
Tim Caswell
ac9a52886d Remove support for sync latest and stable. I never liked them. Fork if you want them
Change-Id: I9092c5625305f54212625af0c16f7ead73a3d9fa
2011-09-28 10:56:16 -07:00
Tim Caswell
273aeeee73 Merge pull request #67 from mmalecki/already-installed
Don't allow installing already installed version.
2011-09-19 15:09:32 -07:00
Maciej Małecki
33c91398bf Don't allow installing already installed version.
Trying to install already installed version causes misleading message
from curl and nvm:

    $ nvm install v0.4.11
    curl: (33) HTTP server doesn't seem to support byte ranges. Cannot
    resume.
    nvm: install v0.4.11 failed!

Of course, resuming interrupted installs is still possible (script
checks for existance of `$VERSION` in `$NVM_DIR`, not `$NVM_DIR/src`).
2011-09-17 13:16:37 +02:00
Tim Caswell
087ce15ccd Merge pull request #62 from welwood08/patch-1
uninstall should delete the extracted source files from the src directory
2011-09-05 11:01:31 -07:00
Will
92703939ee uninstall should delete the extracted source files from the src directory, not nvm root 2011-09-04 14:27:04 +02:00
Tim Caswell
d6ef0c47a5 Merge pull request #60 from croach/master
Fix for Issue #59
2011-08-29 12:40:08 -07:00
Christopher Roach
fd1eb7559b Added a fix for issue #59 2011-08-27 18:02:41 -07:00
Tim Caswell
c562a491ca Merge pull request #57 from ghuntley/zsh
zsh compatibility fixes
2011-08-25 09:16:22 -07:00
Geoffrey Huntley
964e7c303c updated shorthand for -# to --progress-bar on wget emulation function() 2011-08-25 14:32:47 +10:00
Geoffrey Huntley
1251684440 - version detection now works with zsh
- curl routine now compatible with zsh
- changed curl to use --progress-bar instead of unsafe shorthand (-#)
2011-08-25 14:03:13 +10:00
Tim Caswell
2ecd1fac63 Merge pull request #54 from evnm/add-uninstall-and-unalias
Add unalias and uninstall commands
2011-08-19 21:20:50 -07:00
Evan Meagher
46302a25d2 Add unalias and uninstall commands. 2011-08-19 18:00:25 -07:00
Tim Caswell
d5638cb241 Merge pull request #44 from zzen/patch-1
Added copy-packages command
2011-08-18 09:35:12 -07:00
Kieran Huggins
e9f35e7b15 don't shed all over the user's shell 2011-07-28 01:31:35 -04:00
Kieran Huggins
fab5db0ec8 add support for release directories ( e.g. >= v0.5.1 ) 2011-07-27 17:50:41 -04:00
Jakub Nešetřil
4c8d3a70ea Added copy-packages command 2011-07-02 09:14:48 -07:00
Tim Caswell
c10ca74b5b NVM shouldn't really be a NPM module 2011-05-05 13:55:09 -07:00
Tim Caswell
8d97b78da7 Fix a couple little bugs 2011-05-05 13:51:08 -07:00
Tim Caswell
d509e32c6f Merge pull request #24 from carter-thaxton/master.
Force use of unaliased version of ls from shell
2011-05-02 13:46:15 -07:00
Carter Thaxton
61585251f5 Force unaliased use of ls, for those of us who alias ls in their shell 2011-04-09 14:47:50 -07:00
Tim Caswell
83520186d8 Bump version 2011-02-25 12:33:32 -08:00
Tim Caswell
37ffd82af4 Update readme and comment 2011-02-25 11:53:38 -08:00
Isaac Wolkerstorfer
2d4c9b0846 Merge remote-tracking branch 'origin/master'
Conflicts:
	nvm.sh
2011-02-25 20:30:08 +01:00
Isaac Wolkerstorfer
f50e7b1d05 Merge branch 'versions' 2011-02-25 20:14:47 +01:00
Tim Caswell
66a9f01a0e Fix for ZSH by wavded 2011-02-25 09:17:27 -08:00
Tim Caswell
f668d354a9 Update the sample text to reflect current stable 2011-02-18 09:46:47 -08:00
Scott Bronson
d13d6b199a use a subshell instead of setting the START var
also don't try to install npm if node installation fails.
2011-02-13 21:33:28 -08:00
Isaac Wolkerstorfer
cd3304548f Fix some syntax issues 2011-01-29 16:24:42 +01:00
Isaac Wolkerstorfer
45b89ab396 Create alias dir on demand 2011-01-25 20:18:07 +01:00
Isaac Wolkerstorfer
57d62762e1 Don't overwrite existing NVM_DIR vars 2011-01-25 17:29:49 +01:00
Isaac Wolkerstorfer
8ec6fb22fd Create alias dir on demand 2011-01-25 17:12:13 +01:00
Isaac Wolkerstorfer
3d0082fa60 Suppress unnecessary output 2011-01-24 17:11:46 +01:00
Isaac Wolkerstorfer
85566c9682 Merge curl/wget and version changes 2011-01-22 21:52:27 +01:00
Isaac Wolkerstorfer
c060a287d0 Use curl or wget, whichever is available
Also spit out an error message if we have neither.
2011-01-22 21:07:27 +01:00
Isaac Wolkerstorfer
590b283e65 Change version() to nvm_version()
It's a bit less conflict-y
2011-01-22 20:54:15 +01:00
Isaac Wolkerstorfer
a7328b3711 Add output to sync if stable/latest changes 2011-01-22 19:31:20 +01:00
Isaac Wolkerstorfer
861766372d Add a special "default" alias
If you set a "default" alias, it will automatically be loaded when you
start a new shell.
2011-01-22 19:16:24 +01:00
Isaac Wolkerstorfer
f10ac8e8c3 Fix README for ls command 2011-01-22 19:13:02 +01:00
Isaac Wolkerstorfer
a77c632e2a Add aliases to versions
Aliases are stored as plaintext files in the $NVM_DIR/alias dir.
They may store either an explicit version (v0.3.6) or an implied version
("latest"). The latter is a "moving target", and thus possibly
dangerous, but can be useful, too.
2011-01-22 19:12:13 +01:00
Isaac Wolkerstorfer
0f6680e8b7 Use version descriptors for 'install' and 'use'
Allows things like "nvm install latest" or "nvm use stable" or "nvm use 0.2"
2011-01-22 17:57:08 +01:00
Isaac Wolkerstorfer
b2c6be9e08 Show all available versions in ls
Adds a cache of all versions available on nodejs.org using simple empty files as placeholders. When a new version is installed, it will replace the placeholder with a directory.

This makes it easier for users to see what versions are available for install, and what the latest and stable versions are.
2011-01-22 17:48:57 +01:00
39 changed files with 1338 additions and 108 deletions

11
.gitignore vendored
View File

@@ -1,3 +1,14 @@
HEAD
src
v*
alias
# For testing
test/bak
.urchin.log
.urchin_stdout
node_modules/
.DS_Store

View File

@@ -1,2 +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!

21
LICENSE.md Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
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:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
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.

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,37 +1,170 @@
# Node Version Manager
# Node Version Manager [![Build Status](https://travis-ci.org/creationix/nvm.svg?branch=master)][3]
## 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.
To install create a folder somewhere in your filesystem with the "`nvm.sh`" file inside it. I put mine in a folder called "`.nvm`".
### Install script
To install you could use the [install script][2] using cURL:
curl https://raw.githubusercontent.com/creationix/nvm/v0.5.1/install.sh | sh
or Wget:
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.5.1/install.sh | sh
<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
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:
git clone git://github.com/creationix/nvm.git ~/.nvm
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:
. ~/.nvm/nvm.sh
source ~/.nvm/nvm.sh
I always add this line to my ~/.bashrc or ~/.profile file to have it automatically sources 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
To download, compile, and install the v0.2.5 release of node, do this:
To download, compile, and install the latest v0.10.x release of node, do this:
nvm install v0.2.5
nvm install 0.10
And then in any new shell just use the installed version:
nvm use v0.2.5
nvm use 0.10
If you want to see what versions you have installed issue:
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
If you want to see what versions are installed:
nvm ls
If you want to see what versions are available to install:
nvm ls-remote
To restore your PATH, you can deactivate it.
nvm deactivate
To set a default Node version to be used in any new shell, use the alias 'default':
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-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:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
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]. Install Urchin (and other dependencies) like so:
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.
npm run test/fast
Run the slow tests like this.
npm run test/slow
Run all of the tests like this
npm test
Nota bene: Avoid running nvm while the tests are running.
## Bash completion
To activate, you need to source `bash_completion`:
[[ -r $NVM_DIR/bash_completion ]] && . $NVM_DIR/bash_completion
Put the above sourcing line just below the sourcing line for NVM in your profile (`.bashrc`, `.bash_profile`).
### Usage
nvm
$ nvm [tab][tab]
alias copy-packages help list run uninstall version
clear-cache deactivate install ls unalias use
nvm alias
$ nvm alias [tab][tab]
default
$ nvm alias my_alias [tab][tab]
v0.4.11 v0.4.12 v0.6.14
nvm use
$ nvm use [tab][tab]
my_alias default v0.4.11 v0.4.12 v0.6.14
nvm uninstall
$ nvm uninstall [tab][tab]
my_alias default v0.4.11 v0.4.12 v0.6.14
## 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:
https://github.com/creationix/nvm/issues/43
on Arch Linux and other systems using python3 by default, before running *install* you need to
export PYTHON=python2
After the v0.8.6 release of node, nvm tries to install from binary packages. But in some systems, the official binary packages don't work due to incompatibility of shared libs. In such cases, use `-s` option to force install from source:
nvm install -s 0.8.6
[1]: https://github.com/creationix/nvm.git
[2]: https://github.com/creationix/nvm/blob/v0.5.1/install.sh
[3]: https://travis-ci.org/creationix/nvm
[Urchin]: https://github.com/scraperwiki/urchin

90
bash_completion Normal file
View File

@@ -0,0 +1,90 @@
#!/usr/bin/env bash
# bash completion for Node Version Manager (NVM)
__nvm_generate_completion()
{
declare current_word
current_word="${COMP_WORDS[COMP_CWORD]}"
COMPREPLY=($(compgen -W "$1" -- "$current_word"))
return 0
}
__nvm_commands ()
{
declare current_word
declare command
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'
if [ ${#COMP_WORDS[@]} == 4 ]; then
command="${COMP_WORDS[COMP_CWORD-2]}"
case "${command}" in
alias) __nvm_installed_nodes ;;
esac
else
case "${current_word}" in
-*) __nvm_options ;;
*) __nvm_generate_completion "$COMMANDS" ;;
esac
fi
}
__nvm_options ()
{
OPTIONS=''
__nvm_generate_completion "$OPTIONS"
}
__nvm_installed_nodes ()
{
__nvm_generate_completion "$(nvm_ls) $(__nvm_aliases)"
}
__nvm_aliases ()
{
declare aliases
aliases=""
if [ -d $NVM_DIR/alias ]; then
aliases="`cd $NVM_DIR/alias && ls`"
fi
echo "${aliases}"
}
__nvm_alias ()
{
__nvm_generate_completion "$(__nvm_aliases)"
}
__nvm ()
{
declare previous_word
previous_word="${COMP_WORDS[COMP_CWORD-1]}"
case "$previous_word" in
use|run|ls|list|uninstall) __nvm_installed_nodes ;;
alias|unalias) __nvm_alias ;;
*) __nvm_commands ;;
esac
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
# ZSH, load and run bashcompinit before calling the complete function.
if [[ -n ${ZSH_VERSION-} ]]; then
autoload -U +X bashcompinit && bashcompinit
fi
complete -o default -o nospace -F __nvm nvm

View File

@@ -1,22 +1,130 @@
#!/bin/bash
dir=$npm_config_root/.npm/$npm_package_name/$npm_package_version/package
set -e
# add lines to the bashrc.
has=$(cat ~/.bashrc | egrep "^# ADDED BY npm FOR NVM$" || true)
if [ "x$has" != "x" ]; then
exit 0
has() {
type "$1" > /dev/null 2>&1
return $?
}
if [ -z "$NVM_DIR" ]; then
NVM_DIR="$HOME/.nvm"
fi
cat <<NVM_CODE >>~/.bashrc
# ADDED BY npm FOR NVM
. $dir/nvm.sh
# END ADDED BY npm FOR NVM
NVM_CODE
cat <<NVM_HOWTO
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
To use nvm, source your .bashrc file like this:
. ~/.bashrc
or log out and back into your terminal.
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
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 if not specified as environment variable (eg: PROFILE=~/.myprofile).
if [ -z "$PROFILE" ]; then
if [ -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="[ -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 ~/.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 line to the correct file yourself:"
echo
echo " $SOURCE_STR"
echo
else
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"
NVM_HOWTO

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

620
nvm.sh
View File

@@ -5,107 +5,619 @@
# Implemented by Tim Caswell <tim@creationix.com>
# with much bash help from Matthew Ranney
# Auto detect the NVM_DIR using magic bash 3.x stuff
export NVM_DIR=$(dirname ${BASH_ARGV[0]})
NVM_SCRIPT_SOURCE="$_"
nvm()
{
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 nvm_has "unsetopt"; then
unsetopt nomatch 2>/dev/null
NVM_CD_FLAGS="-q"
fi
# 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
# 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
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
local VERSION
# The default version is the current one
if [ -z "$PATTERN" ]; then
PATTERN='current'
fi
VERSION=`nvm_ls $PATTERN | tail -n1`
echo "$VERSION"
if [ "$VERSION" = 'N/A' ]; then
return
fi
}
nvm_remote_version() {
local PATTERN=$1
local VERSION
VERSION=`nvm_ls_remote $PATTERN | tail -n1`
echo "$VERSION"
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_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 [ `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
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 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
}
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() {
if [ $# -lt 1 ]; then
nvm help
return
fi
# Try to figure out the os and arch for binary fetching
local uname="$(uname -a)"
local os=
local arch="$(uname -m)"
local GREP_OPTIONS=''
case "$uname" in
Linux\ *) os=linux ;;
Darwin\ *) os=darwin ;;
SunOS\ *) os=sunos ;;
FreeBSD\ *) os=freebsd ;;
esac
case "$uname" in
*x86_64*) arch=x64 ;;
*i*86*) arch=x86 ;;
*armv6l*) arch=arm-pi ;;
esac
# initialize local variables
local VERSION
local ADDITIONAL_PARAMETERS
local ALIAS
case $1 in
"help" )
echo
echo "Node Version Manager"
echo
echo "Usage:"
echo " nvm help Show this message"
echo " nvm install <version> Download and install a <version>"
echo " nvm use <version> Modify PATH to use <version>"
echo " nvm ls List versions currently installed"
echo " nvm deactivate Undo effects of NVM on current shell"
echo " nvm help Show this message"
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>. 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"
echo " nvm deactivate Undo effects of NVM on current shell"
echo " nvm alias [<pattern>] Show all aliases beginning with <pattern>"
echo " nvm alias <name> <version> Set an alias named <name> pointing to <version>"
echo " nvm unalias <name> Deletes the alias named <name>"
echo " nvm copy-packages <version> Install global NPM packages contained in <version> to current version"
echo
echo "Example:"
echo " nvm install v0.2.5"
echo " nvm use v0.2.5"
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
;;
"install" )
if [ $# -ne 2 ]; then
nvm help
# initialize local variables
local binavail
local t
local url
local sum
local tarball
local nobinary
local version_not_provided=0
local provided_version
if ! nvm_has "curl"; then
echo 'NVM Needs curl to proceed.' >&2;
return 1
fi
if [ $# -lt 2 ]; then
version_not_provided=1
nvm_rc_version
if [ -z "$NVM_RC_VERSION" ]; then
nvm help
return
fi
fi
shift
nobinary=0
if [ "$1" = "-s" ]; then
nobinary=1
shift
fi
if [ "$os" = "freebsd" ]; then
nobinary=1
fi
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
while [ $# -ne 0 ]
do
ADDITIONAL_PARAMETERS="$ADDITIONAL_PARAMETERS $1"
shift
done
[ -d "$NVM_DIR/$VERSION" ] && echo "$VERSION is already installed." && return
# skip binary install if no binary option specified.
if [ $nobinary -ne 1 ]; then
# shortcut - try the binary if possible.
if [ -n "$os" ]; then
if nvm_binary_available "$VERSION"; then
t="$VERSION-$os-$arch"
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 "$tmptarball" $sum && \
tar -xzf "$tmptarball" -C "$tmpdir" --strip-components 1 && \
rm -f "$tmptarball" && \
mv "$tmpdir" "$NVM_DIR/$VERSION"
)
then
nvm use $VERSION
return;
else
echo "Binary download failed, trying source." >&2
rm -rf "$tmptarball" "$tmpdir"
fi
fi
fi
fi
echo "Additional options while compiling: $ADDITIONAL_PARAMETERS"
tarball=''
sum=''
make='make'
if [ "$os" = "freebsd" ]; then
make='gmake'
MAKE_CXX="CXX=c++"
fi
local tmpdir="$NVM_DIR/src"
local tmptarball="$tmpdir/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 (
[ -n "$tarball" ] && \
mkdir -p "$tmpdir" && \
curl -L --progress-bar $tarball -o "$tmptarball" && \
nvm_checksum "$tmptarball" $sum && \
tar -xzf "$tmptarball" -C "$tmpdir" && \
cd "$tmpdir/node-$VERSION" && \
./configure --prefix="$NVM_DIR/$VERSION" $ADDITIONAL_PARAMETERS && \
$make $MAKE_CXX && \
rm -f "$NVM_DIR/$VERSION" 2>/dev/null && \
$make $MAKE_CXX install
)
then
nvm use $VERSION
if ! nvm_has "npm" ; then
echo "Installing npm..."
if [ "`expr "$VERSION" : '\(^v0\.1\.\)'`" != '' ]; then
echo "npm requires node v0.2.3 or higher"
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
fi
else
curl https://npmjs.org/install.sh | clean=yes sh
fi
fi
else
echo "nvm: install $VERSION failed!"
return 1
fi
;;
"uninstall" )
[ $# -ne 2 ] && nvm help && return
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 $PATTERN`
if [ ! -d $NVM_DIR/$VERSION ]; then
echo "$VERSION version is not installed..."
return;
fi
START=`pwd`
mkdir -p "$NVM_DIR/src" && \
cd "$NVM_DIR/src" && \
wget "http://nodejs.org/dist/node-$2.tar.gz" -N && \
tar -xzf "node-$2.tar.gz" && \
cd "node-$2" && \
./configure --prefix="$NVM_DIR/$2" && \
make && \
make install && \
nvm use $2
if ! which npm ; then
echo "Installing npm..."
curl http://npmjs.org/install.sh | sh
fi
cd $START
t="$VERSION-$os-$arch"
# Delete all files related to target version.
rm -rf "$NVM_DIR/src/node-$VERSION" \
"$NVM_DIR/src/node-$VERSION.tar.gz" \
"$NVM_DIR/bin/node-${t}" \
"$NVM_DIR/bin/node-${t}.tar.gz" \
"$NVM_DIR/$VERSION" 2>/dev/null
echo "Uninstalled node $VERSION"
# Rm any aliases that point to uninstalled version.
for ALIAS in `\grep -l $VERSION $NVM_DIR/alias/* 2>/dev/null`
do
nvm unalias `basename $ALIAS`
done
;;
"deactivate" )
if [[ $PATH == *$NVM_DIR/*/bin* ]]; then
if [ `expr "$PATH" : ".*$NVM_DIR/.*/bin.*"` != 0 ] ; then
export PATH=${PATH%$NVM_DIR/*/bin*}${PATH#*$NVM_DIR/*/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
if [ `expr "$MANPATH" : ".*$NVM_DIR/.*/share/man.*"` != 0 ] ; then
export MANPATH=${MANPATH%$NVM_DIR/*/share/man*}${MANPATH#*$NVM_DIR/*/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=${NODE_PATH%$NVM_DIR/*/lib/node_modules*}${NODE_PATH#*$NVM_DIR/*/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 [ $# -ne 2 ]; then
if [ $# -eq 0 ]; then
nvm help
return
return 127
fi
if [ ! -d $NVM_DIR/$2 ]; then
echo "$2 version is not installed yet"
return;
fi
if [[ $PATH == *$NVM_DIR/*/bin* ]]; then
PATH=${PATH%$NVM_DIR/*/bin*}$NVM_DIR/$2/bin${PATH#*$NVM_DIR/*/bin}
if [ $# -eq 1 ]; then
nvm_rc_version
if [ -n "$NVM_RC_VERSION" ]; then
VERSION=`nvm_version $NVM_RC_VERSION`
fi
else
PATH="$NVM_DIR/$2/bin:$PATH"
VERSION=`nvm_version $2`
fi
if [[ $MANPATH == *$NVM_DIR/*/share/man* ]]; then
MANPATH=${MANPATH%$NVM_DIR/*/share/man*}$NVM_DIR/$2/share/man${MANPATH#*$NVM_DIR/*/share/man}
if [ -z "$VERSION" ]; then
nvm help
return 127
fi
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 [ `expr "$PATH" : ".*$NVM_DIR/.*/bin"` != 0 ]; then
PATH=${PATH%$NVM_DIR/*/bin*}$NVM_DIR/$VERSION/bin${PATH#*$NVM_DIR/*/bin}
else
MANPATH="$NVM_DIR/$2/share/man:$MANPATH"
PATH="$NVM_DIR/$VERSION/bin:$PATH"
fi
if [ -z "$MANPATH" ]; then
MANPATH=$(manpath)
fi
MANPATH=${MANPATH#*$NVM_DIR/*/man:}
if [ `expr "$MANPATH" : ".*$NVM_DIR/.*/share/man"` != 0 ]; 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"
fi
if [ `expr "$NODE_PATH" : ".*$NVM_DIR/.*/lib/node_modules.*"` != 0 ]; then
NODE_PATH=${NODE_PATH%$NVM_DIR/*/lib/node_modules*}$NVM_DIR/$VERSION/lib/node_modules${NODE_PATH#*$NVM_DIR/*/lib/node_modules}
else
NODE_PATH="$NVM_DIR/$VERSION/lib/node_modules:$NODE_PATH"
fi
export PATH
hash -r
export MANPATH
export NVM_PATH="$NVM_DIR/$2/lib/node"
export NVM_BIN="$NVM_DIR/$2/bin"
echo "Now using node $2"
export NODE_PATH
export NVM_PATH="$NVM_DIR/$VERSION/lib/node"
export NVM_BIN="$NVM_DIR/$VERSION/bin"
echo "Now using node $VERSION"
;;
"ls" )
if [ $# -ne 1 ]; then
nvm help
"run" )
local provided_version
local has_checked_nvmrc=0
# run given version of node
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
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
for f in $NVM_DIR/v*; do
if [[ $PATH == *$f/bin* ]]; then
echo "v${f##*v} *"
else
echo "v${f##*v}"
if [ `expr "$NODE_PATH" : ".*$NVM_DIR/.*/lib/node_modules.*"` != 0 ]; then
RUN_NODE_PATH=${NODE_PATH%$NVM_DIR/*/lib/node_modules*}$NVM_DIR/$VERSION/lib/node_modules${NODE_PATH#*$NVM_DIR/*/lib/node_modules}
else
RUN_NODE_PATH="$NVM_DIR/$VERSION/lib/node_modules:$NODE_PATH"
fi
echo "Running node $VERSION"
NODE_PATH=$RUN_NODE_PATH $NVM_DIR/$VERSION/bin/node "$@"
;;
"ls" | "list" )
nvm_print_versions "`nvm_ls $2`"
if [ $# -eq 1 ]; then
nvm alias
fi
return
;;
"ls-remote" | "list-remote" )
nvm_print_versions "`nvm_ls_remote $2`"
return
;;
"current" )
nvm_version current
;;
"alias" )
mkdir -p $NVM_DIR/alias
if [ $# -le 2 ]; then
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
echo "$(basename $ALIAS) -> $DEST"
else
echo "$(basename $ALIAS) -> $DEST (-> $VERSION)"
fi
fi
done
return
fi
if [ -z "$3" ]; then
rm -f $NVM_DIR/alias/$2
echo "$2 -> *poof*"
return
fi
mkdir -p $NVM_DIR/alias
VERSION=`nvm_version $3`
if [ $? -ne 0 ]; then
echo "! WARNING: Version '$3' does not exist." >&2
fi
echo $3 > "$NVM_DIR/alias/$2"
if [ ! "$3" = "$VERSION" ]; then
echo "$2 -> $3 (-> $VERSION)"
else
echo "$2 -> $3"
fi
;;
"unalias" )
mkdir -p $NVM_DIR/alias
[ $# -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 127
fi
done
VERSION=`nvm_version $2`
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" )
nvm_version $2
;;
"--version" )
echo "nvm v0.5.1"
;;
* )
nvm help
;;
esac
}
nvm ls default >/dev/null && nvm use default >/dev/null || true

View File

@@ -1,6 +1,33 @@
{ "name" : "nvm"
, "version" : "0.0.6"
, "author" : "Tim Caswell <tim@creationix.org>"
, "scripts" :
{ "install" : "./install.sh" , "uninstall" : "./uninstall.sh" }
{
"name": "nvm",
"version": "0.5.1",
"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

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

View File

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

6
test/fast/Aliases/setup_dir Executable file
View File

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

View File

@@ -0,0 +1,12 @@
#!/bin/sh
mkdir ../../../v0.1.3
mkdir ../../../v0.2.3
. ../../../nvm.sh
# 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 v0.1.3 &&
nvm ls v0.2 | grep v0.2.3

View File

@@ -0,0 +1,18 @@
#!/bin/sh
. ../../../nvm.sh
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 &&
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

View File

@@ -0,0 +1,5 @@
#!/bin/sh
. ../../nvm.sh
nvm 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

@@ -0,0 +1,14 @@
#!/bin/sh
mkdir -p ../../v0.2.3
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 ] || die "Failed to activate v0.2.3"
nvm deactivate &&
[ `expr $PATH : ".*v0.2.3/.*/bin"` = 0 ] || die "Failed to deactivate v0.2.3"

View File

@@ -0,0 +1,6 @@
#!/bin/sh
echo v0.1.2 > ../../alias/test
. ../../nvm.sh
nvm unalias test
! [ -e ../../alias/test ]

View File

@@ -0,0 +1,10 @@
#!/bin/sh
cd ../..
mkdir v0.0.1
mkdir src/node-v0.0.1
. ./nvm.sh
nvm uninstall v0.0.1
[ ! -d 'v0.0.1' ] && [ ! -d 'src/node-v0.0.1' ]

View File

@@ -0,0 +1,4 @@
#!/bin/sh
. ../../nvm.sh
nvm

12
test/fast/setup Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/sh
(
cd ../..
# Back up
type setopt >/dev/null 2>&1 && setopt NULL_GLOB
type shopt >/dev/null 2>&1 && shopt -s nullglob
rm -Rf v* src alias
mkdir src alias
)

13
test/fast/setup_dir Executable file
View File

@@ -0,0 +1,13 @@
#!/bin/sh
(
cd ../..
# Back up
mkdir -p bak
for SRC in v* src alias; do
[ -e "$SRC" ] && mv "$SRC" bak
done
true
)

10
test/fast/teardown Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/sh
# Remove temporary files
(
cd ../..
type setopt >/dev/null 2>&1 && setopt NULL_GLOB
type shopt >/dev/null 2>&1 && shopt -s nullglob
rm -fR v* src alias
)

13
test/fast/teardown_dir Executable file
View File

@@ -0,0 +1,13 @@
#!/bin/sh
(
cd ../..
# Restore
if [ -d bak ]
then
mv bak/* . > /dev/null 2>&1 || sleep 0s
rmdir bak
fi
mkdir -p src alias
)

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

View File

@@ -1,23 +0,0 @@
#!/bin/bash
has=$(cat ~/.bashrc | egrep "^# ADDED BY npm FOR NVM$" || true)
if [ "x$has" == "x" ]; then
echo "doesn't have it, exiting"
exit 0
fi
tmp=~/.bashrc.tmp
cat ~/.bashrc | {
incode=0
while read line; do
if [ "$line" == "# ADDED BY npm FOR NVM" ]; then
incode=1
elif [ "$line" == "# END ADDED BY npm FOR NVM" ] \
&& [ $incode -eq 1 ]; then
incode=0
elif [ $incode -eq 0 ]; then
echo "$line" >> $tmp
fi
done
}
mv $tmp ~/.bashrc