Compare commits

..

236 Commits

Author SHA1 Message Date
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
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
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
26 changed files with 885 additions and 154 deletions

6
.gitignore vendored
View File

@@ -2,3 +2,9 @@ HEAD
src
v*
alias
# For testing
bak
.urchin.log
.DS_Store

21
LICENSE.md Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2010-2013 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.

View File

@@ -4,38 +4,155 @@
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](https://github.com/creationix/nvm/blob/master/install.sh) (requires Git) using cURL:
curl https://raw.github.com/creationix/nvm/master/install.sh | sh
or Wget:
wget -qO- https://raw.github.com/creationix/nvm/master/install.sh | sh
<sub>The script clones the nvm repository to `~/.nvm` and adds the source line to your profile (`~/.bash_profile` or `~/.profile`).</sub>
### 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
. ~/.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` or `~/.profile` 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.4.1 release of node, do this:
To download, compile, and install the latest v0.10.x release of node, do this:
nvm install v0.4.1
nvm install 0.10
And then in any new shell just use the installed version:
nvm use v0.4.1
nvm use 0.10
If you want to see what versions are available:
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 v0.4.1
nvm alias default 0.10
## License
nvm is released under the MIT license.
Copyright (C) 2010-2013 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](https://github.com/scraperwiki/urchin). Install Urchin like so.
wget -O /usr/local/bin https://raw.github.com/scraperwiki/urchin/0c6837cfbdd0963903bf0463b05160c2aecc22ef/urchin
chmod +x /usr/local/bin/urchin
(Or put it some other place in your PATH.)
There are slow tests and fast tests. The slow tests do things like install node
and check that the right versions are used. The fast tests fake this to test
things like aliases and uninstalling. From the root of the nvm git repository,
run the fast tests like this.
urchin test/fast
Run the slow tests like this.
urchin test/slow
Run all of the tests like this
urchin 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

89
bash_completion Normal file
View File

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

59
install-gitless.sh Executable file
View File

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

View File

@@ -1,22 +1,65 @@
#!/bin/bash
dir=$npm_config_root/.npm/$npm_package_name/$npm_package_version/package
NVM_DIR="$HOME/.nvm"
# add lines to the bashrc.
has=$(cat ~/.bashrc | egrep "^# ADDED BY npm FOR NVM$" || true)
if [ "x$has" != "x" ]; then
exit 0
if ! hash git 2>/dev/null; then
echo >&2 "You need to install git - visit http://git-scm.com/downloads"
echo >&2 "or, use install-gitless.sh instead."
exit 1
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 [ -d "$NVM_DIR" ]; then
echo "=> NVM is already installed in $NVM_DIR, trying to update"
echo -ne "\r=> "
cd $NVM_DIR && git pull
else
# Cloning to $NVM_DIR
git clone https://github.com/creationix/nvm.git $NVM_DIR
fi
To use nvm, source your .bashrc file like this:
. ~/.bashrc
or log out and back into your terminal.
echo
NVM_HOWTO
# Detect profile file, .bash_profile has precedence over .profile
if [ ! -z "$1" ]; then
PROFILE="$1"
else
if [ -f "$HOME/.bash_profile" ]; then
PROFILE="$HOME/.bash_profile"
elif [ -f "$HOME/.zshrc" ]; then
PROFILE="$HOME/.zshrc"
elif [ -f "$HOME/.profile" ]; then
PROFILE="$HOME/.profile"
fi
fi
SOURCE_STR="[ -s \$HOME/.nvm/nvm.sh ] && . \$HOME/.nvm/nvm.sh # This loads NVM"
if [ -z "$PROFILE" ] || [ ! -f "$PROFILE" ] ; then
if [ -z $PROFILE ]; then
echo "=> Profile not found. Tried $HOME/.bash_profile and $HOME/.profile"
else
echo "=> Profile $PROFILE not found"
fi
echo "=> Run this script again after running the following:"
echo
echo "\ttouch $HOME/.profile"
echo
echo "-- OR --"
echo
echo "=> Append the following line to the correct file yourself"
echo
echo "\t$SOURCE_STR"
echo
echo "=> Close and reopen your terminal afterwards to start using NVM"
exit
fi
if ! grep -qc 'nvm.sh' $PROFILE; then
echo "=> Appending source string to $PROFILE"
echo "" >> "$PROFILE"
echo $SOURCE_STR >> "$PROFILE"
else
echo "=> Source string already in $PROFILE"
fi
echo "=> Close and reopen your terminal to start using NVM"

459
nvm.sh Normal file → Executable file
View File

@@ -1,3 +1,5 @@
#!/bin/sh
# Node Version Manager
# Implemented as a bash function
# To use source this file from your bash profile
@@ -5,75 +7,163 @@
# Implemented by Tim Caswell <tim@creationix.com>
# with much bash help from Matthew Ranney
# Make zsh glob matching behave same as bash
# This fixes the "zsh: no matches found" errors
if [ ! -z "$(which unsetopt 2>/dev/null)" ]; then
unsetopt nomatch 2>/dev/null
NVM_CD_FLAGS="-q"
fi
# Auto detect the NVM_DIR
if [ ! -d "$NVM_DIR" ]; then
export NVM_DIR=$(cd $(dirname ${BASH_SOURCE[0]:-$0}); pwd)
export NVM_DIR=$(cd $NVM_CD_FLAGS $(dirname ${BASH_SOURCE[0]:-$0}) > /dev/null && pwd)
fi
# Emulate curl with wget, if necessary
if [ ! `which curl` ]; then
if [ `which wget` ]; then
curl() {
ARGS="$* "
ARGS=${ARGS/-s /-q }
ARGS=${ARGS/-\# /}
ARGS=${ARGS/-C - /-c }
ARGS=${ARGS/-o /-O }
nvm_set_nullglob() {
if type setopt > /dev/null 2>&1; then
# Zsh
setopt NULL_GLOB
else
# Bash
shopt -s nullglob
fi
}
wget $ARGS
}
else
NOCURL='nocurl'
curl() { echo 'Need curl or wget to proceed.' >&2; }
fi
fi
# Obtain nvm version from rc file
rc_nvm_version() {
if [ -e .nvmrc ]; then
RC_VERSION=`cat .nvmrc | head -n 1`
echo "Found .nvmrc files with version <$RC_VERSION>"
fi
}
# Expand a version using the version cache
nvm_version()
{
PATTERN=$1
VERSION=''
nvm_version() {
local PATTERN=$1
# The default version is the current one
if [ ! "$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
VERSION=`nvm_ls_remote $PATTERN | tail -n1`
echo "$VERSION"
if [ "$VERSION" = 'N/A' ]; then
return
fi
}
nvm_ls() {
local PATTERN=$1
local VERSIONS=''
if [ "$PATTERN" = 'current' ]; then
echo `node -v 2>/dev/null`
return
fi
if [ -f "$NVM_DIR/alias/$PATTERN" ]; then
nvm_version `cat $NVM_DIR/alias/$PATTERN`
return
fi
# If it looks like an explicit version, don't do anything funny
if [[ "$PATTERN" == v*.*.* ]]; then
VERSION="$PATTERN"
if [[ "$PATTERN" == v?*.?*.?* ]]; then
VERSIONS="$PATTERN"
else
VERSIONS=`find "$NVM_DIR/" -maxdepth 1 -type d -name "v$PATTERN*" -exec basename '{}' ';' \
| sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n`
fi
# The default version is the current one
if [ ! "$PATTERN" -o "$PATTERN" = 'current' ]; then
VERSION=`node -v 2>/dev/null`
fi
if [ "$PATTERN" = 'stable' ]; then
PATTERN='*.*[02468].'
fi
if [ "$PATTERN" = 'latest' ]; then
PATTERN='*.*.'
fi
if [ "$PATTERN" = 'all' ]; then
(cd $NVM_DIR; ls -dG v* 2>/dev/null || echo "N/A")
if [ ! "$VERSIONS" ]; then
echo "N/A"
return
fi
if [ ! "$VERSION" ]; then
VERSION=`(cd $NVM_DIR; ls -d v${PATTERN}* 2>/dev/null) | sort -t. -k 2,1n -k 2,2n -k 3,3n | tail -n1`
fi
if [ ! "$VERSION" ]; then
echo "N/A"
return 13
elif [ -e "$NVM_DIR/$VERSION" ]; then
(cd $NVM_DIR; ls -dG "$VERSION")
echo "$VERSIONS"
return
}
nvm_ls_remote() {
local PATTERN=$1
local VERSIONS
if [ "$PATTERN" ]; then
if echo "${PATTERN}" | \grep -v '^v' ; then
PATTERN=v$PATTERN
fi
else
echo "$VERSION"
PATTERN=".*"
fi
VERSIONS=`curl -s http://nodejs.org/dist/ \
| \egrep -o 'v[0-9]+\.[0-9]+\.[0-9]+' \
| \grep -w "${PATTERN}" \
| sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n`
if [ ! "$VERSIONS" ]; then
echo "N/A"
return
fi
echo "$VERSIONS"
return
}
nvm_checksum() {
if [ "$1" = "$2" ]; then
return
elif [ -z $2 ]; then
echo 'Checksums empty' #missing in raspberry pi binary
return
else
echo 'Checksums do not match.'
return 1
fi
}
nvm()
{
print_versions() {
local OUTPUT=''
local PADDED_VERSION=''
for VERSION in $1; do
PADDED_VERSION=`printf '%10s' $VERSION`
if [[ -d "$NVM_DIR/$VERSION" ]]; then
PADDED_VERSION="\033[0;34m$PADDED_VERSION\033[0m"
fi
OUTPUT="$OUTPUT\n$PADDED_VERSION"
done
echo -e "$OUTPUT"
}
nvm() {
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)"
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
case $1 in
"help" )
echo
@@ -81,54 +171,193 @@ nvm()
echo
echo "Usage:"
echo " nvm help Show this message"
echo " nvm install <version> Download and install a <version>"
echo " nvm install [-s] <version> Download and install a <version>"
echo " nvm uninstall <version> Uninstall a version"
echo " nvm use <version> Modify PATH to use <version>"
echo " nvm ls List versions (installed versions are blue)"
echo " nvm run <version> [<args>] Run <version> with <args> as arguments"
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 sync Update the local cache of available versions"
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.4.0 Install a specific version number"
echo " nvm use stable Use the stable release"
echo " nvm install latest Install the latest, possibly unstable version"
echo " nvm install v0.4.12 Install a specific version number"
echo " nvm use 0.2 Use the latest available 0.2.x release"
echo " nvm alias default v0.4.0 Set v0.4.0 as the default"
echo " nvm run 0.4.12 myApp.js Run myApp.js using node v0.4.12"
echo " nvm alias default 0.4 Auto use the latest installed v0.4.x version"
echo
;;
"install" )
if [ $# -ne 2 ]; then
# initialize local variables
local binavail
local t
local url
local sum
local tarball
local shasum='shasum'
local nobinary
if [ ! `\which curl` ]; then
echo 'NVM Needs curl to proceed.' >&2;
fi
if [ ! `\which shasum` ]; then
shasum='sha1sum'
fi
if [ $# -lt 2 ]; then
nvm help
return
fi
[ "$NOCURL" ] && curl && return
VERSION=`nvm_version $2`
shift
nobinary=0
if [ "$1" = "-s" ]; then
nobinary=1
shift
fi
if [ "$os" = "freebsd" ]; then
nobinary=1
fi
VERSION=`nvm_remote_version $1`
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
binavail=
# binaries started with node 0.8.6
case "$VERSION" in
v0.8.[012345]) binavail=0 ;;
v0.[1234567].*) binavail=0 ;;
*) binavail=1 ;;
esac
if [ $binavail -eq 1 ]; then
t="$VERSION-$os-$arch"
url="http://nodejs.org/dist/$VERSION/node-${t}.tar.gz"
sum=`curl -s http://nodejs.org/dist/$VERSION/SHASUMS.txt | \grep node-${t}.tar.gz | awk '{print $1}'`
local tmpdir="$NVM_DIR/bin/node-${t}"
local tmptarball="$tmpdir/node-${t}.tar.gz"
if (
mkdir -p "$tmpdir" && \
curl -L -C - --progress-bar $url -o "$tmptarball" && \
nvm_checksum `${shasum} "$tmptarball" | awk '{print $1}'` $sum && \
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'
fi
local tmpdir="$NVM_DIR/src"
local tmptarball="$tmpdir/node-$VERSION.tar.gz"
if [ "`curl -Is "http://nodejs.org/dist/$VERSION/node-$VERSION.tar.gz" | \grep '200 OK'`" != '' ]; then
tarball="http://nodejs.org/dist/$VERSION/node-$VERSION.tar.gz"
sum=`curl -s http://nodejs.org/dist/$VERSION/SHASUMS.txt | \grep node-$VERSION.tar.gz | awk '{print $1}'`
elif [ "`curl -Is "http://nodejs.org/dist/node-$VERSION.tar.gz" | \grep '200 OK'`" != '' ]; then
tarball="http://nodejs.org/dist/node-$VERSION.tar.gz"
fi
if (
mkdir -p "$NVM_DIR/src" && \
cd "$NVM_DIR/src" && \
curl -C - -# "http://nodejs.org/dist/node-$VERSION.tar.gz" -o "node-$VERSION.tar.gz" && \
tar -xzf "node-$VERSION.tar.gz" && \
cd "node-$VERSION" && \
./configure --prefix="$NVM_DIR/$VERSION" && \
make && \
[ ! -z $tarball ] && \
mkdir -p "$tmpdir" && \
curl -L --progress-bar $tarball -o "$tmptarball" && \
if [ "$sum" = "" ]; then : ; else nvm_checksum `${shasum} "$tmptarball" | awk '{print $1}'` $sum; fi && \
tar -xzf "$tmptarball" -C "$tmpdir" && \
cd "$tmpdir/node-$VERSION" && \
./configure --prefix="$NVM_DIR/$VERSION" $ADDITIONAL_PARAMETERS && \
$make && \
rm -f "$NVM_DIR/$VERSION" 2>/dev/null && \
make install
$make install
)
then
nvm use $VERSION
if ! which npm ; then
echo "Installing npm..."
curl http://npmjs.org/install.sh | sh
if [[ "`expr match $VERSION '\(^v0\.1\.\)'`" != '' ]]; then
echo "npm requires node v0.2.3 or higher"
elif [[ "`expr match $VERSION '\(^v0\.2\.\)'`" != '' ]]; then
if [[ "`expr match $VERSION '\(^v0\.2\.[0-2]$\)'`" != '' ]]; then
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
if [[ $2 == `nvm_version` ]]; then
echo "nvm: Cannot uninstall currently-active node version, $2."
return 1
fi
VERSION=`nvm_version $2`
if [ ! -d $NVM_DIR/$VERSION ]; then
echo "$VERSION version is not installed..."
return;
fi
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 A in `\grep -l $VERSION $NVM_DIR/alias/* 2>/dev/null`
do
nvm unalias `basename $A`
done
;;
"deactivate" )
if [[ $PATH == *$NVM_DIR/*/bin* ]]; 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"
@@ -141,14 +370,28 @@ nvm()
fi
;;
"use" )
if [ $# -ne 2 ]; then
if [ $# -eq 0 ]; then
nvm help
return
fi
VERSION=`nvm_version $2`
if [ ! -d $NVM_DIR/$VERSION ]; then
if [ $# -eq 1 ]; then
rc_nvm_version
if [ ! -z $RC_VERSION ]; then
VERSION=`nvm_version $RC_VERSION`
fi
else
VERSION=`nvm_version $2`
fi
if [ -z $VERSION ]; then
nvm help
return
fi
if [ -z $VERSION ]; then
VERSION=`nvm_version $2`
fi
if [ ! -d "$NVM_DIR/$VERSION" ]; then
echo "$VERSION version is not installed yet"
return;
return 1
fi
if [[ $PATH == *$NVM_DIR/*/bin* ]]; then
PATH=${PATH%$NVM_DIR/*/bin*}$NVM_DIR/$VERSION/bin${PATH#*$NVM_DIR/*/bin}
@@ -161,35 +404,50 @@ nvm()
MANPATH="$NVM_DIR/$VERSION/share/man:$MANPATH"
fi
export PATH
hash -r
export MANPATH
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_version $2
"run" )
# run given version of node
if [ $# -lt 2 ]; then
nvm help
return
fi
nvm_version all
for P in {stable,latest,current}; do
echo -ne "$P: \t"; nvm_version $P
done
nvm alias
echo "# use 'nvm sync' to update from nodejs.org"
VERSION=`nvm_version $2`
if [ ! -d $NVM_DIR/$VERSION ]; then
echo "$VERSION version is not installed yet"
return;
fi
echo "Running node $VERSION"
$NVM_DIR/$VERSION/bin/node "${@:3}"
;;
"ls" | "list" )
print_versions "`nvm_ls $2`"
if [ $# -eq 1 ]; then
echo -ne "current: \t"; nvm_version current
nvm alias
fi
return
;;
"ls-remote" | "list-remote" )
print_versions "`nvm_ls_remote $2`"
return
;;
"alias" )
mkdir -p $NVM_DIR/alias
if [ $# -le 2 ]; then
(cd $NVM_DIR/alias && for ALIAS in `ls $2* 2>/dev/null`; do
for ALIAS in $(nvm_set_nullglob; echo $NVM_DIR/alias/$2* ); do
DEST=`cat $ALIAS`
VERSION=`nvm_version $DEST`
if [ "$DEST" = "$VERSION" ]; then
echo "$ALIAS -> $DEST"
echo "$(basename $ALIAS) -> $DEST"
else
echo "$ALIAS -> $DEST (-> $VERSION)"
echo "$(basename $ALIAS) -> $DEST (-> $VERSION)"
fi
done)
done
return
fi
if [ ! "$3" ]; then
@@ -200,37 +458,38 @@ nvm()
mkdir -p $NVM_DIR/alias
VERSION=`nvm_version $3`
if [ $? -ne 0 ]; then
echo "! WARNING: Version '$3' does not exist." >&2
echo "! WARNING: Version '$3' does not exist." >&2
fi
echo $3 > "$NVM_DIR/alias/$2"
if [ ! "$3" = "$VERSION" ]; then
echo "$2 -> $3 (-> $VERSION)"
echo "! WARNING: Moving target. Aliases to implicit versions may change without warning."
else
echo "$2 -> $3"
fi
;;
"sync" )
[ "$NOCURL" ] && curl && return
LATEST=`nvm_version latest`
STABLE=`nvm_version stable`
(cd $NVM_DIR
rm -f v* 2>/dev/null
printf "# syncing with nodejs.org..."
for VER in `curl -s http://nodejs.org/dist/ -o - | grep 'node-v.*\.tar\.gz' | sed -e 's/.*node-//' -e 's/\.tar\.gz.*//'`; do
touch $VER
done
echo " done."
)
[ "$STABLE" = `nvm_version stable` ] || echo "NEW stable: `nvm_version stable`"
[ "$LATEST" = `nvm_version latest` ] || echo "NEW latest: `nvm_version latest`"
"unalias" )
mkdir -p $NVM_DIR/alias
[ $# -ne 2 ] && nvm help && return
[ ! -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
fi
VERSION=`nvm_version $2`
ROOT=`nvm use $VERSION && npm -g root`
INSTALLS=`nvm use $VERSION > /dev/null && npm -g -p ll | \grep "$ROOT\/[^/]\+$" | cut -d '/' -f 8 | cut -d ":" -f 2 | \grep -v npm | tr "\n" " "`
npm install -g $INSTALLS
;;
"clear-cache" )
rm -f $NVM_DIR/v* 2>/dev/null
echo "Cache cleared."
;;
"version" )
nvm_version $2
print_versions "`nvm_version $2`"
;;
* )
nvm help
@@ -238,4 +497,4 @@ nvm()
esac
}
nvm ls default >/dev/null 2>&1 && nvm use default >/dev/null
nvm ls default &>/dev/null && nvm use default >/dev/null || true

View File

@@ -1,6 +0,0 @@
{ "name" : "nvm"
, "version" : "0.1.0"
, "author" : "Tim Caswell <tim@creationix.org>"
, "scripts" :
{ "install" : "./install.sh" , "uninstall" : "./uninstall.sh" }
}

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,10 @@
#!/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

View File

@@ -0,0 +1,14 @@
#!/bin/sh
. ../../../nvm.sh
mkdir ../../../v0.0.{1,3,9}
mkdir ../../../v0.3.{1,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,14 @@
#!/bin/sh
mkdir -p ../../v0.2.3
die () { echo $@ ; exit 1; }
[[ $PATH != *v0.2.3/*/bin* ]] || echo "WARNING: Unexpectedly found v0.2.3 already active" >&2
. ../../nvm.sh
nvm use v0.2.3 &&
[[ $PATH == *v0.2.3/*/bin* ]] || die "Failed to activate v0.2.3"
nvm deactivate &&
[[ $PATH != *v0.2.3/*/bin* ]] || 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
)

12
test/fast/setup_dir 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
mkdir -p bak
mv v* src alias bak || sleep 0s
)

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/* . || sleep 0s
rmdir bak
fi
mkdir -p src alias
)

14
test/slow/install Executable file
View File

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

14
test/slow/install from binary Executable file
View File

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

14
test/slow/install from source Executable file
View File

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

View File

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