Compare commits

..

69 Commits

Author SHA1 Message Date
Jordan Harband
6669e91bd8 v0.33.1 2017-02-20 17:59:20 -08:00
John-David Dalton
7c271729ef Enable working without tput. 2017-02-19 23:01:47 -08:00
Jordan Harband
b54e147442 [Fix] nvm unload: run nvm deactivate before unsetting everything.
Fixes #1399.
2017-02-18 00:50:33 -08:00
Jordan Harband
e7e4a9b3d6 [Fix] unset NVM_RC_VERSION env var immediately after it’s no longer needed.
Relates to #1399.
2017-02-18 00:48:41 -08:00
Jordan Harband
49e446dac1 [debug] include mirrors in nvm debug output. 2017-02-14 09:06:23 -08:00
Robin Schneider
1b8b7b31ed Add CII best practices badge
Thanks to @ljharb for applying for it!

Related to: #1395
2017-02-12 11:00:10 +01:00
Jordan Harband
6fc0241c21 [Fix] install.sh: only un-interpolate $HOME for the profile source string.
Fixes #1384.
2017-02-12 00:32:49 -08:00
Jordan Harband
affcc5087c [Fix] set -e: nvm install lts/something: call nvm_ensure_default_set with the proper value.
Fixes #1394.
2017-02-11 23:19:29 -08:00
Ryan Wheale
1b2305232f [install script] Use $HOME variable in NVM_DIR 2017-01-12 10:55:56 -07:00
butlerx
f1a5f2a15f [Docs] [Fix] zsh autochange: only nvm install if we can’t nvm use 2016-12-19 12:00:47 +00:00
Jordan Harband
40e40975eb v0.33.0 2016-12-29 21:22:13 -10:00
Jordan Harband
ae8eb80d0b make release should pop up the EDITOR for the annotated tag. 2016-12-29 21:22:08 -10:00
Jordan Harband
186509be24 [github] modify the issue template 2016-12-28 09:04:12 -10:00
Jordan Harband
853afbf595 Revert "Revert "[Fix] set -u: ensure that potentially unbound variables aren’t called unchecked.""
This reverts commit a8c465018e.

Fixes #1363.
2016-12-26 21:57:55 -08:00
Jordan Harband
a8c465018e Revert "[Fix] set -u: ensure that potentially unbound variables aren’t called unchecked."
This reverts commit 60239e39cd.
2016-12-25 12:18:56 -08:00
Jordan Harband
1cac5194b9 [github] Flesh out issue template a bit. 2016-12-25 12:07:08 -08:00
Peter Dave Hello
71b49f1744 Add GitHub issue template 2016-12-26 02:46:49 +08:00
Jordan Harband
60239e39cd [Fix] set -u: ensure that potentially unbound variables aren’t called unchecked.
Fixes #1363.
2016-12-25 11:31:37 -08:00
Jordan Harband
0f6997d90a [Tests] remove the unused and broken $NVM_PATH. 2016-12-16 11:23:23 -08:00
Jordan Harband
fcd6331f09 [Fix] remove the unused and broken $NVM_PATH.
Added in 359a83e. Fixes #1353.
2016-12-16 10:57:22 -08:00
Peter Dave Hello
2af47b0034 [Docs] Remove mixed addtional indent in the Bash completion codeblock 2016-12-03 21:33:54 +08:00
Peter Dave Hello
7c0dc2be68 [Docs] Make the indent in readme consistenly use soft tabs 2016-12-03 21:32:41 +08:00
Peter Dave Hello
d5340539d9 [Docs] Link version badge to the release page 2016-12-02 19:33:48 +08:00
Peter Dave Hello
45771499ee [Fix] nvm should respect CC/CXX env var
- Also set CC for Freebsd, not only CXX

 - Also set CC=cc, CXX=c++ on Mac OS by default as upstream

Reference:
1bd871655a/configure (L16-L17)
2016-11-29 15:30:01 +08:00
Peter Dave Hello
84575cf353 [Refactor] Use "case" instead of multi "if" 2016-11-28 03:39:48 +08:00
Jordan Harband
47c60dfc1d [Tests] add test to ensure that nvm unload unloads all functions. 2016-11-28 12:50:35 -08:00
Peter Dave Hello
c96c561c88 [Fix] nvm unload missed node_version_has_solaris_binary() 2016-11-28 18:35:32 +08:00
Peter Dave Hello
f29cd1a2ab [Fix] nvm unload missed NVM_CD_FLAGS NVM_BIN NVM_MAKE_JOBS NVM_PATH 2016-11-28 04:14:21 +08:00
Peter Dave Hello
00a1ee6c4d [Fix] nvm unload missed nvm_cache_dir() nvm_cd() 2016-11-28 04:10:42 +08:00
George Adams
a7648ebd9f [Fix] nvm install -s: aix: detect number of threads on aix and not just number of processors 2016-11-23 06:36:52 -05:00
Peter Dave Hello
26fec8035f [Docs] update alpine environment installation info 2016-11-28 02:43:59 +08:00
Peter Dave Hello
c58540666d [Docs] update readme about compile nodejs v0.10+ from src 2016-11-27 21:21:49 +08:00
Gibson Fahnestock
7f1917d0aa [Refactor] Rename NVM_CPU_THREADS to NVM_CPU_CORES 2016-11-24 18:04:14 +00:00
Peter Dave Hello
7d08ad4311 [Tests] also cache $HOME/.ghc for cabal 2016-11-25 23:57:08 +08:00
Jordan Harband
5b820a453c [Refactor] avoid S2181 spellcheck error. 2016-11-25 00:56:28 -06:00
Jordan Harband
af73102481 [Fix] fix a typo i made in 20ae7ee309 2016-11-25 00:35:33 -06:00
Peter Dave Hello
20ae7ee309 [Tests] Run shellcheck on nvm-exec in Travis CI 2016-11-24 14:07:56 +08:00
Peter Dave Hello
ac63638469 [Fix] add missing quotes for $NODE_VERSION in nvm-exec 2016-11-24 13:44:39 +08:00
Peter Dave Hello
7ed1e71944 [Refactor] Add missing backslash for dots
Related: #1279, 2a2b8bd, cadbbce
2016-11-24 13:47:20 +08:00
Peter Dave Hello
b7f9fbd3a7 [Tests] run shellcheck for bash_completion in Travis CI 2016-11-24 16:00:23 +08:00
Peter Dave Hello
9963660a11 [shellcheck] SC1004,SC2086 fixes in bash_completion 2016-11-24 15:59:16 +08:00
Peter Dave Hello
60ba4bca0c [Tests] Remove not working clang part until we refactor the workflow 2016-11-24 14:38:22 +08:00
Peter Dave Hello
e47b313b85 [readme] Auto install not exist version in zsh .nvmrc script
Fixes #1272.
2016-11-14 19:44:55 +08:00
Peter Dave Hello
4b4e71f05c [shellcheck] disable "Check exit code directly" warning on line 273, 666
We need to use both the exit state and result form the previous commit,
so SC2181 should be disabled here.
2016-11-23 22:04:45 +08:00
Peter Dave Hello
5508f8dc70 [Tests] switch to use Cabal to install ShellCheck
1. This can help speed up the apt process since we decrease the
complexity of apt sources and package dependencies resolving by dropping
an additional ppa source.

2. Stack doesn't update ShellCheck to v0.4.5 after it has been released
more than one month, Cabal can provide ShellCheck v0.4.5
2016-11-23 22:04:45 +08:00
Peter Dave Hello
1ffa41886a [New] Install bash programmble completions automatically 2015-05-23 14:07:34 +08:00
Peter Dave Hello
49e8068271 [CI] Drop manual apt source and package installation
- Use Travis CI apt addon source whitelist to load apt source
 - Use Travis CI apt addon to install additional packages

This can prevent duplicating apt package list update and dependencies
calculation which means it can speed up the CI build.
2016-11-17 21:11:48 +08:00
Jordan Harband
ab6be9c0c1 Merge pull request #1300 from PeterDaveHello/clang-llvm
[New] `nvm install -s`: Use clang as C/C++ compiler if detected

Fixes #902
2016-11-17 00:19:04 -08:00
Peter Dave Hello
61ae478c38 [Doc] Add current version on the top of README 2016-11-16 21:23:20 +08:00
Peter Dave Hello
8c03637023 [Fix] nvm install: Handle 'N/A' version instead of asking to install it
Fixes #1304.
2016-11-14 19:31:35 +08:00
Peter Dave Hello
65acb403ce Add nvm_clang_version to ensure clang version > 3.5 2016-11-14 12:28:41 +08:00
Peter Dave Hello
9f67d3ef66 [Tests] Upgrade clang from llvm in Travis-ci 2016-11-14 12:04:36 +08:00
Peter Dave Hello
38934bf16c [New] nvm install -s: Use clang as C/C++ compiler if detected.
Fixes #902.
2016-11-14 05:39:34 +08:00
Peter Dave Hello
03608291a6 [caching] nvm install: Do not remove src dir after compilation succeeds
This will help speed up the installation time for the non-first time
installation, especially can speed up the build time and test time on
Travis-CI as we'll cache .cache dir.
2016-11-14 03:45:52 +08:00
Peter Dave Hello
fd33179119 Revert "Also run git gc after nvm upgraded"
This reverts commit ce7f6d6e52.
2016-11-14 06:19:29 +08:00
Jordan Harband
e5316ddbe3 [Fix] allow uninstalls when files are nonwritable but self-owned.
Fixes #1270.
2016-11-13 00:09:29 -08:00
Peter Dave Hello
eab41ed8ef [Fix] add missing "command" prefix call for some commands 2016-11-13 04:53:41 +08:00
Peter Dave Hello
c5303a6973 Improve nvm_download_artifact() process, fix #1291
- Delete broken/checksum not matched local cache
 - More output message.
2016-11-13 04:02:06 +08:00
Peter Dave Hello
7ef38cf7e8 fix/retab indent in bash_completion [no-ci] 2016-11-11 19:43:36 +08:00
George Adams
8f82eab5db Add AIX support
Currently AIX isn't supported in nvm so I have made a few small changes
to make this work:
change tar to gtar for AIX
change make to gmake for AIX
Set ARCH as ppc64 for AIX
2016-11-10 13:52:00 -05:00
Peter Dave Hello
9c92b5a4ea [New] nvm install: Print the version that is being installed 2016-11-06 20:43:47 +08:00
Peter Dave Hello
f7763c8ba9 [Tests] die() in tests should quote "$@" for echo 2016-11-07 03:34:36 +08:00
Jordan Harband
24f8ae5c46 [New] support external install hook “$NVM_INSTALL_THIRD_PARTY_HOOK”.
Fixes #1207.
2016-11-03 23:42:55 -07:00
Qiangjun Ran
cadbbced20 [Tests] Replace all dots with backslash dots 2016-11-03 23:44:59 -07:00
Qiangjun Ran
2a2b8bdeb3 [Robustness] use backslash when sourcing in case of overridden dot
Fixes #1278.
2016-11-03 23:44:20 -07:00
Jordan Harband
942e9ab1f5 [Fix] bypass aliased cd in a few places.
Fixes #1284.
2016-11-03 10:08:24 -07:00
Peter Dave Hello
a458ccbb87 Retab tab to 4 spaces and use echo instead of cat in install.sh 2016-10-29 11:17:54 +08:00
Peter Dave Hello
ce7f6d6e52 Also run git gc after nvm upgraded 2016-10-28 09:08:54 +08:00
Peter Dave Hello
f3cddf8271 [Doc] Bold leading "Note:" in readme for readability 2016-10-28 11:20:12 +08:00
178 changed files with 789 additions and 506 deletions

41
.github/ISSUE_TEMPLATE.md vendored Normal file
View File

@@ -0,0 +1,41 @@
<!-- Thank you for being interested in nvm! Please help us by filling out the following form if youre having trouble. If you have a feature request, or some other question, please feel free to clear out the form. Thanks! -->
- Operating system and version:
- `nvm debug` output:
<details>
<!-- do not delete the following blank line -->
```sh
```
</details>
- `nvm ls` output:
<details>
<!-- do not delete the following blank line -->
```sh
```
</details>
- How did you install `nvm`? (e.g. install script in readme, homebrew):
- What steps did you perform?
- What happened?
- What did you expect to happen?
- Is there anything in any of your profile files (`.bashrc`, `.bash_profile`, `.zshrc`, etc) that modifies the `PATH`?
<!-- if this does not apply, please delete this section -->
- If you are having installation issues, or getting "N/A", what does `curl -v nodejs.org/dist/` print out?
<details>
<!-- do not delete the following blank line -->
```sh
```
</details>

View File

@@ -7,29 +7,33 @@ addons:
packages:
- gcc-4.8
- g++-4.8
- cabal-install
- ghc
- zsh
- ksh
cache:
directories:
- $HOME/.stack
- $HOME/.ghc
- $HOME/.cabal
- $TRAVIS_BUILD_DIR/.cache
before_install:
- $SHELL --version 2> /dev/null || dpkg -s $SHELL 2> /dev/null || which $SHELL
- curl --version
- wget --version
- if [ -n "${SHELLCHECK-}" ]; then sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 575159689BEFB442 && echo 'deb http://download.fpcomplete.com/ubuntu precise main' | sudo tee /etc/apt/sources.list.d/fpco.list && sudo apt-get update && sudo apt-get install stack bc -y && stack setup && stack install ShellCheck && shellcheck --version ; fi
- if [ -n "${SHELLCHECK-}" ]; then cabal update && cabal install transformers-0.4.3.0 ShellCheck && shellcheck --version ; fi
install:
- (mkdir /tmp/urchin && cd /tmp/urchin && curl -s "$(curl -s https://registry.npmjs.com/urchin | grep -Eo '"tarball":\s*"[^"]+"' | tail -n 1 | awk -F\" '{ print $4 }')" -O && tar -x -f urchin*)
- chmod +x /tmp/urchin/package/urchin
- '[ -z "$WITHOUT_CURL" ] || sudo apt-get remove curl -y'
script:
- if [ -n "${SHELLCHECK-}" ]; then shellcheck -s bash nvm.sh && shellcheck -s sh nvm.sh && shellcheck -s dash nvm.sh && shellcheck -s ksh nvm.sh && shellcheck -s bash install.sh ; fi
- if [ -n "${SHELLCHECK-}" ]; then shellcheck -s bash nvm.sh && shellcheck -s sh nvm.sh && shellcheck -s dash nvm.sh && shellcheck -s ksh nvm.sh ; fi
- if [ -n "${SHELLCHECK-}" ]; then shellcheck -s bash install.sh bash_completion nvm-exec ; fi
- if [ -z "${SHELLCHECK-}" ]; then make TEST_SUITE=$TEST_SUITE URCHIN=/tmp/urchin/package/urchin test-$SHELL ; fi
env:
global:
- CXX=g++-4.8
- CC=gcc-4.8
- PATH=$(echo $PATH | sed 's/::/:/')
- PATH="~/.cabal/bin/:$(echo $PATH | sed 's/::/:/')"
- NVM_DIR="${TRAVIS_BUILD_DIR}"
matrix:
- SHELLCHECK=true

View File

@@ -74,4 +74,4 @@ release: _ensure-tag _ensure-clean
printf "=== Bumping version **$$old_ver** to **$$new_ver** before committing and tagging:\n=== TYPE 'proceed' TO PROCEED, anything else to abort: " && read response && [ "$$response" = 'proceed' ] || { echo 'Aborted.' >&2; exit 2; }; \
replace "$$old_ver" "$$new_ver" -- $(VERSIONED_FILES) && \
git commit -m "v$$new_ver" $(VERSIONED_FILES) && \
git tag -a -m "v$$new_ver" "v$$new_ver"
git tag -a "v$$new_ver"

View File

@@ -1,4 +1,4 @@
# Node Version Manager [![Build Status](https://travis-ci.org/creationix/nvm.svg?branch=master)][3]
# Node Version Manager [![Build Status](https://travis-ci.org/creationix/nvm.svg?branch=master)][3] [![nvm version](https://img.shields.io/badge/version-v0.33.1-yellow.svg)][4] [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/684/badge)](https://bestpractices.coreinfrastructure.org/projects/684)
## Table of Contents
@@ -27,47 +27,47 @@
First you'll need to make sure your system has a c++ compiler. For OS X, Xcode will work, for Ubuntu, the `build-essential` and `libssl-dev` packages work.
Note: `nvm` does not support Windows (see [#284](https://github.com/creationix/nvm/issues/284)). Two alternatives exist, which are neither supported nor developed by us:
**Note:** `nvm` does not support Windows (see [#284](https://github.com/creationix/nvm/issues/284)). Two alternatives exist, which are neither supported nor developed by us:
- [nvm-windows](https://github.com/coreybutler/nvm-windows)
- [nodist](https://github.com/marcelklehr/nodist)
Note: `nvm` does not support [Fish] either (see [#303](https://github.com/creationix/nvm/issues/303)). Alternatives exist, which are neither supported nor developed by us:
**Note:** `nvm` does not support [Fish] either (see [#303](https://github.com/creationix/nvm/issues/303)). Alternatives exist, which are neither supported nor developed by us:
- [bass](https://github.com/edc/bass) allows you to use utilities written for Bash in fish shell
- [fast-nvm-fish](https://github.com/brigand/fast-nvm-fish) only works with version numbers (not aliases) but doesn't significantly slow your shell startup
- [plugin-nvm](https://github.com/derekstavis/plugin-nvm) plugin for [Oh My Fish](https://github.com/oh-my-fish/oh-my-fish), which makes nvm and its completions available in fish shell
Note: We still have some problems with FreeBSD, because there is no official pre-built binary for FreeBSD, and building from source may need [patches](https://www.freshports.org/www/node/files/patch-deps_v8_src_base_platform_platform-posix.cc); see the issue ticket:
**Note:** We still have some problems with FreeBSD, because there is no official pre-built binary for FreeBSD, and building from source may need [patches](https://www.freshports.org/www/node/files/patch-deps_v8_src_base_platform_platform-posix.cc); see the issue ticket:
- [[#900] [Bug] nodejs on FreeBSD need to be patched ](https://github.com/creationix/nvm/issues/900)
- [nodejs/node#3716](https://github.com/nodejs/node/issues/3716)
Note: On OS X, if you do not have Xcode installed and you do not wish to download the ~4.3GB file, you can install the `Command Line Tools`. You can check out this blog post on how to just that:
**Note:** On OS X, if you do not have Xcode installed and you do not wish to download the ~4.3GB file, you can install the `Command Line Tools`. You can check out this blog post on how to just that:
- [How to Install Command Line Tools in OS X Mavericks & Yosemite (Without Xcode)](http://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/)
Note: On OS X, if you have/had a "system" node installed and want to install modules globally, keep in mind that:
**Note:** On OS X, if you have/had a "system" node installed and want to install modules globally, keep in mind that:
- When using nvm you do not need `sudo` to globally install a module with `npm -g`, so instead of doing `sudo npm install -g grunt`, do instead `npm install -g grunt`
- If you have an `~/.npmrc` file, make sure it does not contain any `prefix` settings (which is not compatible with nvm)
- You can (but should not?) keep your previous "system" node install, but nvm will only be available to your user account (the one used to install nvm). This might cause version mismatches, as other users will be using `/usr/local/lib/node_modules/*` VS your user account using `~/.nvm/versions/node/vX.X.X/lib/node_modules/*`
Homebrew installation is not supported. If you have issues with homebrew-installed `nvm`, please `brew uninstall` it, and install it using the instructions below, before filing an issue.
Note: If you're using `zsh` you can easily install `nvm` as a zsh plugin. Install [`zsh-nvm`](https://github.com/lukechilds/zsh-nvm) and run `nvm upgrade` to upgrade.
**Note:** If you're using `zsh` you can easily install `nvm` as a zsh plugin. Install [`zsh-nvm`](https://github.com/lukechilds/zsh-nvm) and run `nvm upgrade` to upgrade.
Note: Git versions before v1.7 may face a problem of cloning nvm source from GitHub via https protocol, and there is also different behavior of git before v1.6, so the minimum required git version is v1.7.0 and we recommend v1.7.9.5 as it's the default version of the wildly used Ubuntu 12.04 LTS. If you are interested in the problem we mentioned here, please refer to GitHub's [HTTPS cloning errors](https://help.github.com/articles/https-cloning-errors/) article.
**Note:** Git versions before v1.7 may face a problem of cloning nvm source from GitHub via https protocol, and there is also different behavior of git before v1.6, so the minimum required git version is v1.7.0 and we recommend v1.7.9.5 as it's the default version of the wildly used Ubuntu 12.04 LTS. If you are interested in the problem we mentioned here, please refer to GitHub's [HTTPS cloning errors](https://help.github.com/articles/https-cloning-errors/) article.
### Install script
To install or update nvm, you can use the [install script][2] using cURL:
```sh
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash
```
or Wget:
```sh
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash
```
<sub>The script clones the nvm repository to `~/.nvm` and adds the source line to your profile (`~/.bash_profile`, `~/.zshrc`, `~/.profile`, or `~/.bashrc`).</sub>
@@ -82,7 +82,7 @@ Eg: `curl ... | NVM_DIR=/usr/local/nvm bash` for a global install.
<sub>*NB. The installer can use `git`, `curl`, or `wget` to download `nvm`, whatever is available.*</sub>
Note: On OS X, if you get `nvm: command not found` after running the install script, your system may not have a [.bash_profile file] where the command is set up. Simply create one with `touch ~/.bash_profile` and run the install script again.
**Note:** On OS X, if you get `nvm: command not found` after running the install script, your system may not have a [.bash_profile file] where the command is set up. Simply create one with `touch ~/.bash_profile` and run the install script again.
If the above doesn't fix the problem, open your `.bash_profile` and add the following line of code:
@@ -322,7 +322,9 @@ load-nvmrc() {
if [ -n "$nvmrc_path" ]; then
local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
if [ "$nvmrc_node_version" != "N/A" ] && [ "$nvmrc_node_version" != "$node_version" ]; then
if [ "$nvmrc_node_version" = "N/A" ]; then
nvm install
elif [ "$nvmrc_node_version" != "$node_version" ]; then
nvm use
fi
elif [ "$node_version" != "$(nvm version default)" ]; then
@@ -429,13 +431,13 @@ In order to provide the best performance (and other optimisations), nvm will dow
Alpine Linux, unlike mainstream/traditional Linux distributions, is based on [busybox](https://www.busybox.net/), a very compact (~5MB) Linux distribution. Busybox (and thus Alpine Linux) uses a different C/C++ stack to most mainstream/traditional Linux distributions - [musl](https://www.musl-libc.org/). This makes binary programs built for such mainstream/traditional incompatible with Alpine Linux, thus we cannot simply `nvm install X` on Alpine Linux and expect the downloaded binary to run correctly - you'll likely see "...does not exist" errors if you try that.
There is a `-s` flag for `nvm install` which requests nvm download Node source and compile it locally but currently (May 2016), this is not available for Node versions newer than v0.10 so unless you need an older Node version, this won't help you. Work is in progress on source-builds for newer Node versions but is not yet complete.
There is a `-s` flag for `nvm install` which requests nvm download Node source and compile it locally.
If installing nvm on Alpine Linux *is* still what you want or need to do, you should be able to achieve this by running the following from you Alpine Linux shell:
```sh
apk add bash
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | /bin/bash
apk add -U curl bash ca-certificates openssl ncurses coreutils python2 make gcc g++ libgcc linux-headers
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash
```
The Node project has some desire but no concrete plans (due to the overheads of building, testing and support) to offer Alpine-compatible binaries.
@@ -466,7 +468,8 @@ After the v0.8.6 release of node, nvm tries to install from binary packages. But
If setting the `default` alias does not establish the node version in new shells (i.e. `nvm current` yields `system`), ensure that the system's node PATH is set before the `nvm.sh` source line in your shell profile (see [#658](https://github.com/creationix/nvm/issues/658))
[1]: https://github.com/creationix/nvm.git
[2]: https://github.com/creationix/nvm/blob/v0.32.1/install.sh
[2]: https://github.com/creationix/nvm/blob/v0.33.1/install.sh
[3]: https://travis-ci.org/creationix/nvm
[4]: https://github.com/creationix/nvm/releases/tag/v0.33.1
[Urchin]: https://github.com/scraperwiki/urchin
[Fish]: http://fishshell.com

View File

@@ -17,11 +17,11 @@ __nvm_commands ()
current_word="${COMP_WORDS[COMP_CWORD]}"
COMMANDS='\
help install uninstall use run exec \
alias unalias reinstall-packages \
current list ls list-remote ls-remote \
clear-cache deactivate unload \
COMMANDS='
help install uninstall use run exec
alias unalias reinstall-packages
current list ls list-remote ls-remote
clear-cache deactivate unload
version which'
if [ ${#COMP_WORDS[@]} == 4 ]; then
@@ -56,8 +56,8 @@ __nvm_aliases ()
{
declare aliases
aliases=""
if [ -d $NVM_DIR/alias ]; then
aliases="$(cd $NVM_DIR/alias && find $PWD -type f | sed "s:$PWD/::")"
if [ -d "$NVM_DIR/alias" ]; then
aliases="$(cd "$NVM_DIR/alias" && command find "$PWD" -type f | command sed "s:$PWD/::")"
fi
echo "${aliases} node stable unstable iojs"
}

View File

@@ -7,11 +7,11 @@ nvm_has() {
}
nvm_install_dir() {
echo "${NVM_DIR:-"$HOME/.nvm"}"
printf %s "${NVM_DIR:-"$HOME/.nvm"}"
}
nvm_latest_version() {
echo "v0.32.1"
echo "v0.33.1"
}
#
@@ -240,23 +240,24 @@ nvm_check_global_modules() {
)"
if [ "${MODULE_COUNT}" != '0' ]; then
cat <<-'END_MESSAGE'
=> You currently have modules installed globally with `npm`. These will no
=> longer be linked to the active version of Node when you install a new node
=> with `nvm`; and they may (depending on how you construct your `$PATH`)
=> override the binaries of modules installed with `nvm`:
# shellcheck disable=SC2016
echo '=> You currently have modules installed globally with `npm`. These will no'
# shellcheck disable=SC2016
echo '=> longer be linked to the active version of Node when you install a new node'
# shellcheck disable=SC2016
echo '=> with `nvm`; and they may (depending on how you construct your `$PATH`)'
# shellcheck disable=SC2016
echo '=> override the binaries of modules installed with `nvm`:'
echo
END_MESSAGE
command printf %s\\n "$NPM_GLOBAL_MODULES"
cat <<-'END_MESSAGE'
=> If you wish to uninstall them at a later point (or re-install them under your
=> `nvm` Nodes), you can remove them from the system Node as follows:
$ nvm use system
$ npm uninstall -g a_module
END_MESSAGE
echo '=> If you wish to uninstall them at a later point (or re-install them under your'
# shellcheck disable=SC2016
echo '=> `nvm` Nodes), you can remove them from the system Node as follows:'
echo
echo ' $ nvm use system'
echo ' $ npm uninstall -g a_module'
echo
fi
}
@@ -289,10 +290,12 @@ nvm_do_install() {
local NVM_PROFILE
NVM_PROFILE="$(nvm_detect_profile)"
local INSTALL_DIR
INSTALL_DIR="$(nvm_install_dir)"
local PROFILE_INSTALL_DIR
PROFILE_INSTALL_DIR="$(nvm_install_dir| sed "s:^$HOME:\$HOME:")"
SOURCE_STR="\nexport NVM_DIR=\"$INSTALL_DIR\"\n[ -s \"\$NVM_DIR/nvm.sh\" ] && . \"\$NVM_DIR/nvm.sh\" # This loads nvm\n"
SOURCE_STR="\nexport NVM_DIR=\"${PROFILE_INSTALL_DIR}\"\n[ -s \"\$NVM_DIR/nvm.sh\" ] && \\. \"\$NVM_DIR/nvm.sh\" # This loads nvm\n"
COMPLETION_STR="[ -s \"\$NVM_DIR/bash_completion\" ] && \\. \"\$NVM_DIR/bash_completion\" # This loads nvm bash_completion\n"
BASH_OR_ZSH=false
if [ -z "${NVM_PROFILE-}" ] ; then
echo "=> Profile not found. Tried ${NVM_PROFILE} (as defined in \$PROFILE), ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile."
@@ -302,17 +305,33 @@ nvm_do_install() {
echo "=> Append the following lines to the correct file yourself:"
command printf "${SOURCE_STR}"
else
case "${NVM_PROFILE-}" in
".bashrc" | ".bash_profile" | ".zshrc")
BASH_OR_ZSH=true
;;
esac
if ! command grep -qc '/nvm.sh' "$NVM_PROFILE"; then
echo "=> Appending source string to $NVM_PROFILE"
command printf "$SOURCE_STR" >> "$NVM_PROFILE"
echo "=> Appending nvm source string to $NVM_PROFILE"
command printf "${SOURCE_STR}" >> "$NVM_PROFILE"
else
echo "=> Source string already in ${NVM_PROFILE}"
echo "=> nvm source string already in ${NVM_PROFILE}"
fi
# shellcheck disable=SC2016
if ${BASH_OR_ZSH} && ! command grep -qc '$NVM_DIR/bash_completion' "$NVM_PROFILE"; then
echo "=> Appending bash_completion source string to $NVM_PROFILE"
command printf "$COMPLETION_STR" >> "$NVM_PROFILE"
else
echo "=> bash_completion source string already in ${NVM_PROFILE}"
fi
fi
if ${BASH_OR_ZSH} && [ -z "${NVM_PROFILE-}" ] ; then
echo "=> Please also append the following lines to the if you are using bash/zsh shell:"
command printf "${COMPLETION_STR}"
fi
# Source nvm
# shellcheck source=/dev/null
. "${INSTALL_DIR}/nvm.sh"
\. "$(nvm_install_dir)/nvm.sh"
nvm_check_global_modules
@@ -321,7 +340,10 @@ nvm_do_install() {
nvm_reset
echo "=> Close and reopen your terminal to start using nvm or run the following to use it now:"
command printf "$SOURCE_STR"
command printf "${SOURCE_STR}"
if ${BASH_OR_ZSH} ; then
command printf " && ${COMPLETION_STR}"
fi
}
#

View File

@@ -2,10 +2,11 @@
DIR="$(command cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. "$DIR/nvm.sh" --no-use
# shellcheck disable=SC1090
\. "$DIR/nvm.sh" --no-use
if [ -n "$NODE_VERSION" ]; then
nvm use $NODE_VERSION > /dev/null || exit 127
nvm use "$NODE_VERSION" > /dev/null || exit 127
elif ! nvm use >/dev/null 2>&1; then
echo "No NODE_VERSION provided; no .nvmrc file found" >&2
exit 127

237
nvm.sh Normal file → Executable file
View File

@@ -22,6 +22,11 @@ nvm_echo() {
}
}
nvm_cd() {
# shellcheck disable=SC1001,SC2164
\cd "$@"
}
nvm_err() {
>&2 nvm_echo "$@"
}
@@ -42,7 +47,9 @@ nvm_is_alias() {
nvm_has_colors() {
local NVM_COLORS
if nvm_has tput; then
NVM_COLORS="$(tput -T "${TERM:-vt100}" colors)"
fi
[ "${NVM_COLORS:--1}" -ge 8 ]
}
@@ -115,7 +122,7 @@ if [ -z "${NVM_DIR-}" ]; then
NVM_SCRIPT_SOURCE="${BASH_SOURCE[0]}"
fi
# shellcheck disable=SC1001
NVM_DIR="$(cd ${NVM_CD_FLAGS} "$(dirname "${NVM_SCRIPT_SOURCE:-$0}")" > /dev/null && \pwd)"
NVM_DIR="$(nvm_cd ${NVM_CD_FLAGS} "$(dirname "${NVM_SCRIPT_SOURCE:-$0}")" > /dev/null && \pwd)"
export NVM_DIR
fi
unset NVM_SCRIPT_SOURCE 2> /dev/null
@@ -187,6 +194,10 @@ nvm_rc_version() {
fi
}
nvm_clang_version() {
clang --version | command awk '{ if ($2 == "version") print $3; else if ($3 == "version") print $4 }' | command sed 's/-.*$//g'
}
nvm_version_greater() {
command awk 'BEGIN {
if (ARGV[1] == "" || ARGV[2] == "") exit(1)
@@ -259,8 +270,7 @@ nvm_ensure_version_installed() {
EXIT_CODE="$?"
local NVM_VERSION_DIR
if [ "${EXIT_CODE}" != "0" ] || ! nvm_is_version_installed "${LOCAL_VERSION}"; then
VERSION="$(nvm_resolve_alias "${PROVIDED_VERSION}")"
if [ $? -eq 0 ]; then
if VERSION="$(nvm_resolve_alias "${PROVIDED_VERSION}")"; then
nvm_err "N/A: version \"${PROVIDED_VERSION} -> ${VERSION}\" is not yet installed."
nvm_err ""
nvm_err "You need to run \"nvm install ${PROVIDED_VERSION}\" to install it before using it."
@@ -371,7 +381,7 @@ nvm_remote_versions() {
NVM_LS_REMOTE_PRE_MERGED_OUTPUT=''
local NVM_LS_REMOTE_POST_MERGED_OUTPUT
NVM_LS_REMOTE_POST_MERGED_OUTPUT=''
if [ -z "${NVM_FLAVOR}" ] || [ "${NVM_FLAVOR}" = "${NVM_NODE_PREFIX}" ]; then
if [ -z "${NVM_FLAVOR-}" ] || [ "${NVM_FLAVOR-}" = "${NVM_NODE_PREFIX}" ]; then
local NVM_LS_REMOTE_OUTPUT
NVM_LS_REMOTE_OUTPUT=$(NVM_LTS="${NVM_LTS-}" nvm_ls_remote "${PATTERN-}") &&:
NVM_LS_REMOTE_EXIT_CODE=$?
@@ -383,8 +393,8 @@ nvm_remote_versions() {
local NVM_LS_REMOTE_IOJS_EXIT_CODE
NVM_LS_REMOTE_IOJS_EXIT_CODE=0
local NVM_LS_REMOTE_IOJS_OUTPUT
if [ -z "${NVM_LTS}" ] && ( \
[ -z "${NVM_FLAVOR}" ] || [ "${NVM_FLAVOR}" = "${NVM_IOJS_PREFIX}" ] \
if [ -z "${NVM_LTS-}" ] && ( \
[ -z "${NVM_FLAVOR-}" ] || [ "${NVM_FLAVOR-}" = "${NVM_IOJS_PREFIX}" ] \
); then
NVM_LS_REMOTE_IOJS_OUTPUT=$(nvm_ls_remote_iojs "${PATTERN-}") &&:
NVM_LS_REMOTE_IOJS_EXIT_CODE=$?
@@ -445,7 +455,7 @@ nvm_format_version() {
if [ "${NUM_GROUPS}" -lt 3 ]; then
nvm_format_version "${VERSION%.}.0"
else
nvm_echo "${VERSION}" | cut -f1-3 -d.
nvm_echo "${VERSION}" | command cut -f1-3 -d.
fi
}
@@ -653,8 +663,7 @@ nvm_alias() {
nvm_ls_current() {
local NVM_LS_CURRENT_NODE_PATH
NVM_LS_CURRENT_NODE_PATH="$(command which node 2> /dev/null)"
if [ $? -ne 0 ]; then
if ! NVM_LS_CURRENT_NODE_PATH="$(command which node 2> /dev/null)"; then
nvm_echo 'none'
elif nvm_tree_contains_path "$(nvm_version_dir iojs)" "${NVM_LS_CURRENT_NODE_PATH}"; then
nvm_add_iojs_prefix "$(iojs --version 2>/dev/null)"
@@ -887,7 +896,7 @@ nvm_ls() {
PATTERN='v'
SEARCH_PATTERN='.*'
else
SEARCH_PATTERN="$(echo "${PATTERN}" | sed "s#\.#\\\.#g;")"
SEARCH_PATTERN="$(echo "${PATTERN}" | command sed "s#\.#\\\.#g;")"
fi
if [ -n "${NVM_DIRS_TO_SEARCH1}${NVM_DIRS_TO_SEARCH2}${NVM_DIRS_TO_SEARCH3}" ]; then
VERSIONS="$(command find "${NVM_DIRS_TO_SEARCH1}"/* "${NVM_DIRS_TO_SEARCH2}"/* "${NVM_DIRS_TO_SEARCH3}"/* -name . -o -type d -prune -o -path "${PATTERN}*" \
@@ -983,9 +992,9 @@ nvm_ls_remote_index_tab() {
;;
esac
local SORT_COMMAND
SORT_COMMAND='sort'
SORT_COMMAND='command sort'
case "${FLAVOR}" in
node) SORT_COMMAND='sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n' ;;
node) SORT_COMMAND='command sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n' ;;
esac
local PATTERN
@@ -1018,7 +1027,7 @@ nvm_ls_remote_index_tab() {
local LTS_VERSION
command mkdir -p "$(nvm_alias_path)/lts"
nvm_echo "${VERSION_LIST}" \
| awk '{
| command awk '{
if ($10 ~ /^\-?$/) { next }
if ($10 && !a[tolower($10)]++) {
if (alias) { print alias, version }
@@ -1200,26 +1209,26 @@ nvm_checksum() {
elif nvm_has "sha1" && ! nvm_is_alias "sha1"; then
NVM_CHECKSUM="$(command sha1 -q "${1-}")"
elif nvm_has "shasum" && ! nvm_is_alias "shasum"; then
NVM_CHECKSUM="$(shasum "${1-}" | command awk '{print $1}')"
NVM_CHECKSUM="$(command shasum "${1-}" | command awk '{print $1}')"
else
nvm_err 'Unaliased sha1sum, sha1, or shasum not found.'
return 2
fi
else
if nvm_has "sha256sum" && ! nvm_is_alias "sha256sum"; then
NVM_CHECKSUM="$(sha256sum "${1-}" | command awk '{print $1}')"
NVM_CHECKSUM="$(command sha256sum "${1-}" | command awk '{print $1}')"
elif nvm_has "shasum" && ! nvm_is_alias "shasum"; then
NVM_CHECKSUM="$(shasum -a 256 "${1-}" | command awk '{print $1}')"
NVM_CHECKSUM="$(command shasum -a 256 "${1-}" | command awk '{print $1}')"
elif nvm_has "sha256" && ! nvm_is_alias "sha256"; then
NVM_CHECKSUM="$(sha256 -q "${1-}" | command awk '{print $1}')"
NVM_CHECKSUM="$(command sha256 -q "${1-}" | command awk '{print $1}')"
elif nvm_has "gsha256sum" && ! nvm_is_alias "gsha256sum"; then
NVM_CHECKSUM="$(gsha256sum "${1-}" | command awk '{print $1}')"
NVM_CHECKSUM="$(command gsha256sum "${1-}" | command awk '{print $1}')"
elif nvm_has "openssl" && ! nvm_is_alias "openssl"; then
NVM_CHECKSUM="$(openssl dgst -sha256 "${1-}" | rev | command awk '{print $1}' | rev)"
NVM_CHECKSUM="$(command openssl dgst -sha256 "${1-}" | rev | command awk '{print $1}' | rev)"
elif nvm_has "libressl" && ! nvm_is_alias "libressl"; then
NVM_CHECKSUM="$(libressl dgst -sha256 "${1-}" | rev | command awk '{print $1}' | rev)"
NVM_CHECKSUM="$(command libressl dgst -sha256 "${1-}" | rev | command awk '{print $1}' | rev)"
elif nvm_has "bssl" && ! nvm_is_alias "bssl"; then
NVM_CHECKSUM="$(bssl sha256sum "${1-}" | command awk '{print $1}')"
NVM_CHECKSUM="$(command bssl sha256sum "${1-}" | command awk '{print $1}')"
else
nvm_err 'Unaliased sha256sum, shasum, sha256, gsha256sum, openssl, libressl, or bssl not found.'
nvm_err 'WARNING: Continuing *without checksum verification*'
@@ -1440,6 +1449,7 @@ nvm_get_os() {
Darwin\ *) NVM_OS=darwin ;;
SunOS\ *) NVM_OS=sunos ;;
FreeBSD\ *) NVM_OS=freebsd ;;
AIX\ *) NVM_OS=aix ;;
esac
nvm_echo "${NVM_OS-}"
}
@@ -1455,13 +1465,13 @@ nvm_get_arch() {
# isainfo to get the instruction set supported by the
# kernel.
if [ "_$NVM_OS" = "_sunos" ]; then
HOST_ARCH=$(pkg_info -Q MACHINE_ARCH pkg_install)
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then
HOST_ARCH=$(isainfo -n)
if HOST_ARCH=$(pkg_info -Q MACHINE_ARCH pkg_install); then
HOST_ARCH=$(echo "${HOST_ARCH}" | command tail -1)
else
HOST_ARCH=$(echo "$HOST_ARCH" | command tail -1)
HOST_ARCH=$(isainfo -n)
fi
elif [ "_$NVM_OS" = "_aix" ]; then
HOST_ARCH=ppc64
else
HOST_ARCH="$(command uname -m)"
fi
@@ -1562,8 +1572,6 @@ nvm_install_binary() {
local VERSION
VERSION="$(nvm_strip_iojs_prefix "${PREFIXED_VERSION}")"
local VERSION_PATH
if [ -z "$(nvm_get_os)" ]; then
return 2
fi
@@ -1578,14 +1586,24 @@ nvm_install_binary() {
local TMPDIR
local VERSION_PATH
local NODE_OR_IOJS
if [ "${FLAVOR}" = 'node' ]; then
NODE_OR_IOJS="${FLAVOR}"
fi
nvm_echo "Downloading and installing ${NODE_OR_IOJS-} ${VERSION}..."
TARBALL="$(nvm_download_artifact "${FLAVOR}" binary "${TYPE-}" "${VERSION}" | command tail -1)"
if [ -f "${TARBALL}" ]; then
TMPDIR="$(dirname "${TARBALL}")/files"
fi
local tar
tar='tar'
if [ "${NVM_OS}" = 'aix' ]; then
tar='gtar'
fi
if (
[ -n "${TMPDIR-}" ] && \
command mkdir -p "${TMPDIR}" && \
command tar -x${tar_compression_flag}f "${TARBALL}" -C "${TMPDIR}" --strip-components 1 && \
command "${tar}" -x${tar_compression_flag}f "${TARBALL}" -C "${TMPDIR}" --strip-components 1 && \
VERSION_PATH="$(nvm_version_path "${PREFIXED_VERSION}")" && \
command mkdir -p "${VERSION_PATH}" && \
command mv "${TMPDIR}/"* "${VERSION_PATH}" && \
@@ -1717,10 +1735,19 @@ nvm_download_artifact() {
TARBALL_URL="${MIRROR}/${SLUG}.tar.${COMPRESSION}"
fi
if [ -r "${TARBALL}" ]; then
nvm_err "Local cache found: $(nvm_sanitize_path "${TARBALL}")"
if nvm_compare_checksum "${TARBALL}" "${CHECKSUM}" >/dev/null 2>&1; then
nvm_err "Checksums match! Using existing downloaded archive $(nvm_sanitize_path "${TARBALL}")"
else
nvm_echo "Downloading ${TARBALL_URL}..."
nvm_echo "${TARBALL}"
return 0
fi
nvm_compare_checksum "${TARBALL}" "${CHECKSUM}"
nvm_err "Checksum check failed!"
nvm_err "Removing the broken local cache..."
command rm -rf "${TARBALL}"
fi
nvm_err "Downloading ${TARBALL_URL}..."
nvm_download -L -C - --progress-bar "${TARBALL_URL}" -o "${TARBALL}" || (
command rm -rf "${TARBALL}" "${tmpdir}"
nvm_err "Binary download from ${TARBALL_URL} failed, trying source."
@@ -1737,7 +1764,6 @@ nvm_download_artifact() {
command rm -rf "${tmpdir}/files"
return 6
)
fi
nvm_echo "${TARBALL}"
}
@@ -1753,26 +1779,33 @@ nvm_get_make_jobs() {
fi
local NVM_OS
NVM_OS="$(nvm_get_os)"
local NVM_CPU_THREADS
if [ "_$NVM_OS" = "_linux" ]; then
NVM_CPU_THREADS="$(nvm_grep -c -E '^processor.+: [0-9]+' /proc/cpuinfo)"
elif [ "_$NVM_OS" = "_freebsd" ] || [ "_$NVM_OS" = "_darwin" ]; then
NVM_CPU_THREADS="$(sysctl -n hw.ncpu)"
elif [ "_$NVM_OS" = "_sunos" ]; then
NVM_CPU_THREADS="$(psrinfo | wc -l)"
fi
if ! nvm_is_natural_num "$NVM_CPU_THREADS" ; then
nvm_err 'Can not determine how many thread(s) we can use, set to only 1 now.'
nvm_err 'Please report an issue on GitHub to help us make it better and run it faster on your computer!'
local NVM_CPU_CORES
case "_$NVM_OS" in
"_linux")
NVM_CPU_CORES="$(nvm_grep -c -E '^processor.+: [0-9]+' /proc/cpuinfo)"
;;
"_freebsd" | "_darwin")
NVM_CPU_CORES="$(sysctl -n hw.ncpu)"
;;
"_sunos")
NVM_CPU_CORES="$(psrinfo | wc -l)"
;;
"_aix")
NVM_CPU_CORES="$(pmcycles -m | wc -l)"
;;
esac
if ! nvm_is_natural_num "$NVM_CPU_CORES" ; then
nvm_err 'Can not determine how many core(s) are available, running in single-threaded mode.'
nvm_err 'Please report an issue on GitHub to help us make nvm run faster on your computer!'
NVM_MAKE_JOBS=1
else
nvm_echo "Detected that you have $NVM_CPU_THREADS CPU thread(s)"
if [ "$NVM_CPU_THREADS" -gt 2 ]; then
NVM_MAKE_JOBS=$((NVM_CPU_THREADS - 1))
nvm_echo "Set the number of jobs to $NVM_CPU_THREADS - 1 = $NVM_MAKE_JOBS jobs to speed up the build"
nvm_echo "Detected that you have $NVM_CPU_CORES CPU core(s)"
if [ "$NVM_CPU_CORES" -gt 2 ]; then
NVM_MAKE_JOBS=$((NVM_CPU_CORES - 1))
nvm_echo "Running with $NVM_MAKE_JOBS threads to speed up the build"
else
NVM_MAKE_JOBS=1
nvm_echo 'Number of CPU thread(s) less or equal to 2 will have only one job a time for `make`'
nvm_echo 'Number of CPU core(s) less than or equal to 2, running in single-threaded mode'
fi
fi
}
@@ -1822,9 +1855,24 @@ nvm_install_source() {
local make
make='make'
if [ "${NVM_OS}" = 'freebsd' ]; then
local MAKE_CXX
case "${NVM_OS}" in
'freebsd')
make='gmake'
MAKE_CXX='CXX=c++'
MAKE_CXX="CC=${CC:-cc} CXX=${CXX:-c++}"
;;
'darwin')
MAKE_CXX="CC=${CC:-cc} CXX=${CXX:-c++}"
;;
'aix')
make='gmake'
;;
esac
if nvm_has "clang++" && nvm_has "clang" && nvm_version_greater_than_or_equal_to nvm_clang_version 3.5; then
if [ -z "${CC-}" ] || [ -z "${CXX-}" ] ; then
nvm_echo "Clang v3.5+ detected! CC or CXX not specified, will use Clang as c/c++ compiler!"
MAKE_CXX="CC=${CC:-cc} CXX=${CXX:-c++}"
fi
fi
local tar_compression_flag
@@ -1833,24 +1881,29 @@ nvm_install_source() {
tar_compression_flag='J'
fi
local tar
tar='tar'
if [ "${NVM_OS}" = 'aix' ]; then
tar='gtar'
fi
local TARBALL
local TMPDIR
local VERSION_PATH
# shellcheck disable=SC2086
if (
TARBALL="$(nvm_download_artifact "${FLAVOR}" source "${TYPE}" "${VERSION}" | command tail -1)" && \
[ -f "${TARBALL}" ] && \
TMPDIR="$(dirname "${TARBALL}")/files" && \
if (
# shellcheck disable=SC2086
command mkdir -p "${TMPDIR}" && \
command tar -x${tar_compression_flag}f "${TARBALL}" -C "${TMPDIR}" --strip-components 1 && \
command "${tar}" -x${tar_compression_flag}f "${TARBALL}" -C "${TMPDIR}" --strip-components 1 && \
VERSION_PATH="$(nvm_version_path "${PREFIXED_VERSION}")" && \
cd "${TMPDIR}" && \
nvm_cd "${TMPDIR}" && \
./configure --prefix="${VERSION_PATH}" $ADDITIONAL_PARAMETERS && \
$make -j "${NVM_MAKE_JOBS}" ${MAKE_CXX-} && \
command rm -f "${VERSION_PATH}" 2>/dev/null && \
$make -j "${NVM_MAKE_JOBS}" ${MAKE_CXX-} install && \
command rm -rf "${TMPDIR}"
$make -j "${NVM_MAKE_JOBS}" ${MAKE_CXX-} install
); then
if ! nvm_has "npm" ; then
nvm_echo 'Installing npm...'
@@ -1870,6 +1923,7 @@ nvm_install_source() {
fi
nvm_err "nvm: install ${VERSION} failed!"
command rm -rf "${TMPDIR-}"
return 1
}
@@ -2056,8 +2110,8 @@ nvm_check_file_permissions() {
fi
return 2
fi
elif [ -e "$FILE" ] && [ ! -w "$FILE" ]; then
nvm_err "file is not writable: $(nvm_sanitize_path "$FILE")"
elif [ -e "$FILE" ] && [ ! -w "$FILE" ] && [ ! -O "$FILE" ]; then
nvm_err "file is not writable or self-owned: $(nvm_sanitize_path "$FILE")"
if [ "${ZSH_HAS_NONOMATCH_UNSET}" -eq 1 ] && nvm_has "setopt"; then
setopt nomatch
fi
@@ -2190,6 +2244,8 @@ nvm() {
nvm_err "\$NVM_DIR: '$(nvm_sanitize_path "$NVM_DIR")'"
nvm_err "\$PREFIX: '$(nvm_sanitize_path "$PREFIX")'"
nvm_err "\$NPM_CONFIG_PREFIX: '$(nvm_sanitize_path "$NPM_CONFIG_PREFIX")'"
nvm_err "\$NVM_NODEJS_ORG_MIRROR: '${NVM_NODEJS_ORG_MIRROR}'"
nvm_err "\$NVM_IOJS_ORG_MIRROR: '${NVM_IOJS_ORG_MIRROR}'"
local NVM_DEBUG_OUTPUT
for NVM_DEBUG_COMMAND in 'nvm current' 'which node' 'which iojs' 'which npm' 'npm config get prefix' 'npm root -g'
do
@@ -2264,11 +2320,13 @@ nvm() {
nvm_rc_version
if [ $version_not_provided -eq 1 ]; then
if [ -z "$NVM_RC_VERSION" ]; then
unset NVM_RC_VERSION
>&2 nvm --help
return 127
fi
fi
provided_version="$NVM_RC_VERSION"
unset NVM_RC_VERSION
fi
elif [ $# -gt 0 ]; then
shift
@@ -2353,6 +2411,30 @@ nvm() {
return $?
fi
local NVM_INSTALL_SUCCESS
NVM_INSTALL_SUCCESS=false
if [ -n "${NVM_INSTALL_THIRD_PARTY_HOOK-}" ]; then
nvm_err '** $NVM_INSTALL_THIRD_PARTY_HOOK env var set; dispatching to third-party installation method **'
local NVM_METHOD_PREFERENCE
NVM_METHOD_PREFERENCE='binary'
if [ $nobinary -eq 1 ]; then
NVM_METHOD_PREFERENCE='source'
fi
local VERSION_PATH
VERSION_PATH="$(nvm_version_path "${VERSION}")"
local EXIT_CODE
"${NVM_INSTALL_THIRD_PARTY_HOOK}" "${VERSION}" "${FLAVOR}" std "${NVM_METHOD_PREFERENCE}" "${VERSION_PATH}" || {
EXIT_CODE=$?
nvm_err '*** Third-party $NVM_INSTALL_THIRD_PARTY_HOOK env var failed to install! ***'
return $EXIT_CODE
}
if ! nvm_is_version_installed "${VERSION}"; then
nvm_err '*** Third-party $NVM_INSTALL_THIRD_PARTY_HOOK env var claimed to succeed, but failed to install! ***'
return 33
fi
NVM_INSTALL_SUCCESS=true
else
if [ "_$NVM_OS" = "_freebsd" ]; then
# node.js and io.js do not have a FreeBSD binary
nobinary=1
@@ -2365,7 +2447,6 @@ nvm() {
fi
fi
local NVM_INSTALL_SUCCESS
# skip binary install if "nobinary" option specified.
if [ $nobinary -ne 1 ] && nvm_binary_available "$VERSION"; then
if nvm_install_binary "${FLAVOR}" std "${VERSION}"; then
@@ -2382,8 +2463,14 @@ nvm() {
fi
fi
fi
if [ "$NVM_INSTALL_SUCCESS" = true ] && nvm use "$VERSION"; then
if [ -n "${LTS-}" ]; then
nvm_ensure_default_set "lts/${LTS}"
else
nvm_ensure_default_set "$provided_version"
fi
if [ ! -z "$REINSTALL_PACKAGES_FROM" ] \
&& [ "_$REINSTALL_PACKAGES_FROM" != "_N/A" ]; then
nvm reinstall-packages "$REINSTALL_PACKAGES_FROM"
@@ -2500,7 +2587,7 @@ nvm() {
nvm_echo "$NVM_DIR/*/lib/node_modules removed from \$NODE_PATH"
fi
fi
unset NVM_BIN NVM_PATH
unset NVM_BIN
;;
"use" )
local PROVIDED_VERSION
@@ -2536,6 +2623,7 @@ nvm() {
PROVIDED_VERSION="$NVM_RC_VERSION"
VERSION="$(nvm_version "$PROVIDED_VERSION")"
fi
unset NVM_RC_VERSION
else
VERSION="$(nvm_match_version "$PROVIDED_VERSION")"
fi
@@ -2568,10 +2656,14 @@ nvm() {
fi
return 8
fi
if [ "${VERSION}" = 'N/A' ]; then
nvm_err "N/A: version \"${PROVIDED_VERSION} -> ${VERSION}\" is not yet installed."
nvm_err ""
nvm_err "You need to run \"nvm install ${PROVIDED_VERSION}\" to install it before using it."
return 3
# This nvm_ensure_version_installed call can be a performance bottleneck
# on shell startup. Perhaps we can optimize it away or make it faster.
if ! nvm_ensure_version_installed "${VERSION}"; then
elif ! nvm_ensure_version_installed "${VERSION}"; then
return $?
fi
@@ -2594,7 +2686,6 @@ nvm() {
fi
export PATH
hash -r
export NVM_PATH="$NVM_VERSION_DIR/lib/node"
export NVM_BIN="$NVM_VERSION_DIR/bin"
if [ "${NVM_SYMLINK_CURRENT-}" = true ]; then
command rm -f "$NVM_DIR/current" && ln -s "$NVM_VERSION_DIR" "$NVM_DIR/current"
@@ -2657,6 +2748,7 @@ nvm() {
if [ -n "$NVM_RC_VERSION" ]; then
VERSION="$(nvm_version "$NVM_RC_VERSION")" ||:
fi
unset NVM_RC_VERSION
if [ "${VERSION:-N/A}" = 'N/A' ]; then
>&2 nvm --help
return 127
@@ -2677,6 +2769,7 @@ nvm() {
fi
fi
VERSION="$(nvm_version "$NVM_RC_VERSION")" ||:
unset NVM_RC_VERSION
else
shift
fi
@@ -2752,6 +2845,7 @@ nvm() {
nvm_rc_version
fi
provided_version="$NVM_RC_VERSION"
unset NVM_RC_VERSION
VERSION="$(nvm_version "$provided_version")" ||:
else
shift
@@ -2867,6 +2961,7 @@ nvm() {
provided_version="${NVM_RC_VERSION}"
VERSION=$(nvm_version "${NVM_RC_VERSION}") ||:
fi
unset NVM_RC_VERSION
elif [ "_${1}" != '_system' ]; then
VERSION="$(nvm_version "${provided_version}")" ||:
else
@@ -3022,7 +3117,7 @@ nvm() {
for LINK in $LINKS; do
set +f; unset IFS # restore variable expansion
if [ -n "$LINK" ]; then
(cd "$LINK" && npm link)
(nvm_cd "$LINK" && npm link)
fi
done
set +f; unset IFS # restore variable expansion in case $LINKS was empty
@@ -3070,16 +3165,17 @@ nvm() {
NVM_VERSION_ONLY=true NVM_LTS="${NVM_LTS-}" nvm_remote_version "${PATTERN:-node}"
;;
"--version" )
nvm_echo '0.32.1'
nvm_echo '0.33.1'
;;
"unload" )
nvm deactivate >/dev/null 2>&1
unset -f nvm \
nvm_iojs_prefix nvm_node_prefix \
nvm_add_iojs_prefix nvm_strip_iojs_prefix \
nvm_is_iojs_version nvm_is_alias \
nvm_ls_remote nvm_ls_remote_iojs nvm_ls_remote_index_tab \
nvm_ls nvm_remote_version nvm_remote_versions \
nvm_install_binary \
nvm_install_binary nvm_clang_version \
nvm_get_mirror nvm_get_download_slug nvm_download_artifact \
nvm_install_source nvm_check_file_permissions \
nvm_print_versions nvm_compute_checksum nvm_checksum \
@@ -3091,7 +3187,7 @@ nvm() {
nvm_binary_available nvm_prepend_path nvm_strip_path \
nvm_num_version_groups nvm_format_version nvm_ensure_version_prefix \
nvm_normalize_version nvm_is_valid_version \
nvm_ensure_version_installed \
nvm_ensure_version_installed nvm_cache_dir \
nvm_version_path nvm_alias_path nvm_version_dir \
nvm_find_nvmrc nvm_find_up nvm_tree_contains_path \
nvm_version_greater nvm_version_greater_than_or_equal_to \
@@ -3099,15 +3195,18 @@ nvm() {
nvm_has_system_node nvm_has_system_iojs \
nvm_download nvm_get_latest nvm_has \
nvm_supports_source_options nvm_auto nvm_supports_xz \
nvm_echo nvm_err nvm_grep \
nvm_echo nvm_err nvm_grep nvm_cd \
nvm_die_on_prefix nvm_get_make_jobs nvm_get_minor_version \
nvm_has_solaris_binary nvm_is_merged_node_version \
nvm_is_natural_num nvm_is_version_installed \
nvm_list_aliases nvm_make_alias nvm_print_alias_path \
nvm_print_default_alias nvm_print_formatted_alias nvm_resolve_local_alias \
nvm_sanitize_path nvm_has_colors nvm_process_parameters \
node_version_has_solaris_binary iojs_version_has_solaris_binary \
> /dev/null 2>&1
unset RC_VERSION NVM_NODEJS_ORG_MIRROR NVM_IOJS_ORG_MIRROR NVM_DIR \
NVM_CD_FLAGS NVM_BIN NVM_MAKE_JOBS \
> /dev/null 2>&1
unset RC_VERSION NVM_NODEJS_ORG_MIRROR NVM_IOJS_ORG_MIRROR NVM_DIR NVM_CD_FLAGS > /dev/null 2>&1
;;
* )
>&2 nvm --help

View File

@@ -1,6 +1,6 @@
{
"name": "nvm",
"version": "0.32.1",
"version": "0.33.1",
"description": "Node Version Manager - Simple bash script to manage multiple active node.js versions",
"directories": {
"test": "test"

View File

@@ -1,8 +1,8 @@
#!/bin/sh
. ../../../nvm.sh
\. ../../../nvm.sh
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
OUTPUT="$(nvm alias foo/bar baz 2>&1)"
EXPECTED_OUTPUT="Aliases in subdirectories are not supported."

View File

@@ -1,8 +1,8 @@
#!/bin/sh
. ../../../nvm.sh
\. ../../../nvm.sh
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
OUTPUT="$(nvm unalias foo/bar 2>&1)"
EXPECTED_OUTPUT="Aliases in subdirectories are not supported."

View File

@@ -1,9 +1,9 @@
#!/bin/sh
. ../../../nvm.sh
. ../../common.sh
\. ../../../nvm.sh
\. ../../common.sh
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
if [ -n "$ZSH_VERSION" ]; then
# set clobber option in order to test that this does not produce any

View File

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

View File

@@ -1,9 +1,9 @@
#!/bin/sh
. ../../../nvm.sh
. ../../common.sh
\. ../../../nvm.sh
\. ../../common.sh
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
NVM_ALIAS_OUTPUT=$(nvm alias | strip_colors)

View File

@@ -1,9 +1,9 @@
#!/bin/sh
. ../../../nvm.sh
. ../../common.sh
\. ../../../nvm.sh
\. ../../common.sh
die () { echo $@ ; cleanup ; exit 1; }
die () { echo "$@" ; cleanup ; exit 1; }
cleanup () {
rm -rf "$(nvm_alias_path)/stable"
rm -rf "$(nvm_alias_path)/unstable"

View File

@@ -1,9 +1,9 @@
#!/bin/sh
. ../../../nvm.sh
. ../../common.sh
\. ../../../nvm.sh
\. ../../common.sh
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
NVM_ALIAS_OUTPUT="$(nvm alias | strip_colors)"
echo "$NVM_ALIAS_OUTPUT" | \grep -F 'test-stable-1 -> 0.0.1 (-> v0.0.1)' \

View File

@@ -1,9 +1,9 @@
#!/bin/sh
. ../../../common.sh
\. ../../../common.sh
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
. ../../../../nvm.sh
\. ../../../../nvm.sh
ALIAS="$(nvm_resolve_alias loopback | strip_colors)"
[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_alias loopback was not ∞; got $ALIAS"

View File

@@ -1,9 +1,9 @@
#!/bin/sh
. ../../../common.sh
\. ../../../common.sh
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
. ../../../../nvm.sh
\. ../../../../nvm.sh
ALIAS="$(nvm_resolve_local_alias loopback | strip_colors)"
[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_local_alias loopback was not ∞; got $ALIAS"

View File

@@ -2,12 +2,12 @@
set -ex
. ../../../../nvm.sh
. ../../../common.sh
\. ../../../../nvm.sh
\. ../../../common.sh
LTS_ALIAS_PATH="$(nvm_alias_path)/lts"
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
[ ! -d "${LTS_ALIAS_PATH}" ] || die "'${LTS_ALIAS_PATH}' exists and should not"

View File

@@ -1,6 +1,6 @@
#!/bin/sh
. ../../../../nvm.sh
\. ../../../../nvm.sh
LTS_ALIAS_PATH="$(nvm_alias_path)/lts"

View File

@@ -1,6 +1,6 @@
#!/bin/sh
. ../../../../nvm.sh
\. ../../../../nvm.sh
LTS_ALIAS_PATH="$(nvm_alias_path)/lts"

View File

@@ -1,10 +1,10 @@
#!/bin/sh
. ../../common.sh
\. ../../common.sh
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
. ../../../nvm.sh
\. ../../../nvm.sh
nvm alias default 0.1 >/dev/null || die "'nvm alias default 0.1' failed"

View File

@@ -1,8 +1,8 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
. ../../../nvm.sh
\. ../../../nvm.sh
EXIT_CODE=$(nvm_resolve_alias ; echo $?)
[ $EXIT_CODE = "1" ] || die "nvm_resolve_alias without an argument did not return 1; got $EXIT_CODE"

View File

@@ -1,8 +1,8 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
. ../../../nvm.sh
\. ../../../nvm.sh
EXIT_CODE=$(nvm_resolve_local_alias ; echo $?)
[ "_$EXIT_CODE" = "_1" ] || die "nvm_resolve_local_alias without an argument did not return 1; got $EXIT_CODE"

View File

@@ -1,12 +1,12 @@
#!/bin/sh
. ../../../nvm.sh
\. ../../../nvm.sh
mkdir -p "${NVM_DIR}/v0.0.2"
mkdir -p "${NVM_DIR}/v0.0.20"
mkdir -p "${NVM_DIR}/versions/node/v0.12.0"
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
# The result should contain only the appropriate version numbers.

View File

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

View File

@@ -1,11 +1,11 @@
#!/bin/sh
. ../../../nvm.sh
\. ../../../nvm.sh
mkdir "${NVM_DIR}/v0.0.2"
mkdir "${NVM_DIR}/v0.0.20"
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
# The result should contain only the appropriate version numbers.

View File

@@ -1,12 +1,12 @@
#!/bin/sh
. ../../../nvm.sh
\. ../../../nvm.sh
mkdir "${NVM_DIR}/v0.1.3"
mkdir "${NVM_DIR}/v0.2.3"
mkdir "${NVM_DIR}/v0.20.3"
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
# The result should contain only the appropriate version numbers.

View File

@@ -1,6 +1,6 @@
#!/bin/sh
. ../../../nvm.sh
\. ../../../nvm.sh
nvm ls nonexistent_version
[ "$?" = "3" ]

View File

@@ -1,6 +1,6 @@
#!/bin/sh
. ../../../nvm.sh
\. ../../../nvm.sh
nvm ls io
[ "$?" = "3" ]

View File

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

View File

@@ -1,8 +1,8 @@
#!/bin/sh
. ../../../nvm.sh
\. ../../../nvm.sh
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
mkdir "${NVM_DIR}/v0.2.3"
mkdir "${NVM_DIR}/v0.3.3"

View File

@@ -1,8 +1,8 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
. ../../../nvm.sh
\. ../../../nvm.sh
mkdir -p "${NVM_DIR}/v0.0.1"
mkdir -p "${NVM_DIR}/v0.0.3"

View File

@@ -1,6 +1,6 @@
#!/bin/sh
. ../../../nvm.sh
\. ../../../nvm.sh
mkdir "${NVM_DIR}/v0.0.1"
mkdir "${NVM_DIR}/v0.0.3"

View File

@@ -1,6 +1,6 @@
#!/bin/sh
. ../../../nvm.sh
\. ../../../nvm.sh
mkdir "${NVM_DIR}/v0.1.3"
mkdir "${NVM_DIR}/v0.2.3"

View File

@@ -1,6 +1,6 @@
#!/bin/sh
. ../../../nvm.sh
\. ../../../nvm.sh
mkdir "${NVM_DIR}/v0.1.3"
mkdir "${NVM_DIR}/v0.2.3"

View File

@@ -1,8 +1,8 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
. ../../../nvm.sh
\. ../../../nvm.sh
mkdir -p "${NVM_DIR}/v0.0.1"
mkdir -p "${NVM_DIR}/v0.0.3"

View File

@@ -1,8 +1,8 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
. ../../../nvm.sh
\. ../../../nvm.sh
mkdir -p "${NVM_DIR}/versions/node/v0.12.1"
mkdir "${NVM_DIR}/v0.1.3"

View File

@@ -1,6 +1,6 @@
#!/bin/sh
. ../../../nvm.sh
\. ../../../nvm.sh
mkdir "${NVM_DIR}/v0.1.2"

View File

@@ -2,7 +2,7 @@
set -ex
. ../../nvm.sh
\. ../../nvm.sh
nvm alias test v0.1.2

View File

@@ -2,9 +2,9 @@
set -ex
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
. ../../nvm.sh
\. ../../nvm.sh
nvm deactivate 2>&1

View File

@@ -4,21 +4,19 @@ set -ex
mkdir -p ../../v0.2.3
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
[ `expr $PATH : ".*v0.2.3/.*/bin"` = 0 ] || echo "WARNING: Unexpectedly found v0.2.3 already active" >&2
. ../../nvm.sh
\. ../../nvm.sh
nvm use --delete-prefix v0.2.3 || die "Failed to activate v0.2.3"
[ `expr "$PATH" : ".*v0.2.3/.*/bin"` != 0 ] || die "PATH not set up properly"
[ `expr "$NODE_PATH" : ".*v0.2.3/.*/lib/node_modules"` = 0 ] || die "NODE_PATH should not contain (npm root -g)"
[ `expr "$NVM_BIN" : ".*v0.2.3/bin"` != 0 ] || die "NODE_BIN should contain bin directory path"
[ `expr "$NVM_PATH" : ".*v0.2.3/lib/node"` != 0 ] || die "NODE_PATH should contain lib node directory path"
# ^ note: NODE_PATH should not contain `npm root -g` since globals should not be requireable
[ `expr "$NVM_BIN" : ".*v0.2.3/bin"` != 0 ] || die "NODE_BIN should contain bin directory path"
nvm deactivate || die "Failed to deactivate v0.2.3"
[ `expr "$PATH" : ".*v0.2.3/.*/bin"` = 0 ] || die "PATH not cleaned properly"
[ `expr "$NODE_PATH" : ".*v0.2.3/.*/lib/node_modules"` = 0 ] || die "NODE_PATH not cleaned properly"
[ "_$NVM_BIN" = "_" ] || die "NVM_BIN should be unset: got '$NVM_BIN'"
[ "_$NVM_PATH" = "_" ] || die "NVM_PATH should be unset: got '$NVM_PATH'"

View File

@@ -2,12 +2,12 @@
set -ex
die () { echo $@ ; cleanup ; exit 1; }
die () { echo "$@" ; cleanup ; exit 1; }
cleanup () {
rm -rf "${NVM_DIR}/v0.10.4"
}
. ../../nvm.sh
\. ../../nvm.sh
mkdir "${NVM_DIR}/v0.10.4"

View File

@@ -2,9 +2,9 @@
set -ex
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
. ../../nvm.sh
\. ../../nvm.sh
set +ex # needed for stderr
OUTPUT="$(nvm install invalid.invalid 2>&1)"

View File

@@ -6,7 +6,7 @@ ALIAS_PATH="../../alias"
echo v0.1.2 > "${ALIAS_PATH}/test"
. ../../nvm.sh
\. ../../nvm.sh
nvm unalias test

View File

@@ -2,12 +2,25 @@
set -ex
die () { echo $@ ; exit 1; }
BEFORE="./before.tmp"
AFTER="./after.tmp"
. ../../nvm.sh
cleanup () { rm -f "${BEFORE}" "${AFTER}"; }
die () { echo "$@" ; cleanup ; exit 1; }
typeset -f | awk '/ \(\) $/ && !/^main / {print $1}' > "${BEFORE}"
\. ../../nvm.sh
type nvm > /dev/null 2>&1 || die "nvm not loaded"
nvm unload
typeset -f | awk '/ \(\) $/ && !/^main / {print $1}' > "${AFTER}"
! type nvm > /dev/null 2>&1 || die "nvm not unloaded"
DIFF="$(diff "${BEFORE}" "${AFTER}" ||:)"
[ -z "${DIFF}" ] || die "function pollution found: ${DIFF}"
cleanup

View File

@@ -2,13 +2,13 @@
set -ex
die () { echo $@ ; cleanup ; exit 1; }
die () { echo "$@" ; cleanup ; exit 1; }
cleanup() {
rm -rf "$(nvm_alias_path)/foo"
}
. ../../nvm.sh
\. ../../nvm.sh
nvm_make_alias foo foo

View File

@@ -2,9 +2,9 @@
set -ex
. ../common.sh
\. ../common.sh
die () { echo $@ ; cleanup ; exit 1; }
die () { echo "$@" ; cleanup ; exit 1; }
VERSION="v3.99.0"
@@ -13,7 +13,7 @@ cleanup() {
rm -rf "$(nvm_version_path "iojs-${VERSION}")"
}
. ../../nvm.sh
\. ../../nvm.sh
nvm deactivate || die "unable to deactivate; current: >$(nvm current)<"

View File

@@ -5,9 +5,9 @@ set -ex
cleanup() {
unset -f nvm_has_system_node nvm_print_npm_version
}
die() { echo $@ ; cleanup ; exit 1; }
die() { echo "$@" ; cleanup ; exit 1; }
. ../../nvm.sh
\. ../../nvm.sh
nvm_has_system_node() { return 0; }
nvm_print_npm_version() { command printf ' (npm v1.2.3)'; }

View File

@@ -3,7 +3,7 @@
set -ex
export NVM_SYMLINK_CURRENT=true
. ../../nvm.sh
\. ../../nvm.sh
rm -rf "${NVM_DIR}/v0.10.29"
mkdir "${NVM_DIR}/v0.10.29"

View File

@@ -2,7 +2,7 @@
set -ex
. ../../nvm.sh
\. ../../nvm.sh
TEST_NODE_VERSION="v0.10.29"

View File

@@ -2,6 +2,6 @@
set -ex
. ../../nvm.sh
\. ../../nvm.sh
nvm

View File

@@ -3,5 +3,5 @@
set -ex
set -- yes
. ../../nvm.sh
\. ../../nvm.sh
[ "$1" = yes ]

View File

@@ -1,9 +1,9 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
. ../../../nvm.sh
. ../../common.sh
\. ../../../nvm.sh
\. ../../common.sh
assert_not_ok iojs_version_has_solaris_binary ""
assert_not_ok iojs_version_has_solaris_binary "foo"

View File

@@ -1,9 +1,9 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
. ../../../nvm.sh
. ../../common.sh
\. ../../../nvm.sh
\. ../../common.sh
# Invalid version numbers fail
assert_not_ok node_version_has_solaris_binary ""

View File

@@ -2,17 +2,17 @@
set -ex
die () { echo $@ ; cleanup ; exit 1; }
die () { echo "$@" ; cleanup ; exit 1; }
cleanup() {
unset -f nvm_download nvm_ls_remote nvm_ls_remote_iojs
}
. ../../../nvm.sh
\. ../../../nvm.sh
nvm deactivate 2>/dev/null || die 'unable to deactivate'
. ../../common.sh
\. ../../common.sh
REMOTE="$PWD/mocks/nvm_ls_remote.txt"
nvm_ls_remote() {

View File

@@ -2,15 +2,15 @@
set -ex
die () { echo $@ ; cleanup ; exit 1; }
die () { echo "$@" ; cleanup ; exit 1; }
cleanup() {
unset -f nvm_remote_version
}
. ../../../nvm.sh
\. ../../../nvm.sh
. ../../common.sh
\. ../../common.sh
nvm_remote_version() {
echo "NVM_VERSION_ONLY:${NVM_VERSION_ONLY-},NVM_LTS:${NVM_LTS-},PATTERN:${PATTERN-}"

View File

@@ -1,8 +1,8 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
. ../../../nvm.sh
\. ../../../nvm.sh
[ "_$(nvm_add_iojs_prefix 1)" = "_iojs-v1" ] || die '"nvm_add_iojs_prefix 1" did not return "iojs-v1"'
[ "_$(nvm_add_iojs_prefix iojs-1)" = "_iojs-v1" ] || die '"nvm_add_iojs_prefix iojs-1" did not return "iojs-v1"'

View File

@@ -1,12 +1,12 @@
#!/bin/sh
die () { echo $@ ; cleanup ; exit 1; }
die () { echo "$@" ; cleanup ; exit 1; }
cleanup () {
rm -rf ../../../alias/test
}
. ../../../nvm.sh
\. ../../../nvm.sh
OUTPUT="$(nvm_alias 2>&1)"
EXPECTED_OUTPUT='An alias is required.'

View File

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

View File

@@ -4,9 +4,9 @@ cleanup () {
rm tmp/emptyfile tmp/testfile
rmdir tmp
}
die () { echo $@ ; cleanup; exit 1; }
die () { echo "$@" ; cleanup; exit 1; }
. ../../../nvm.sh
\. ../../../nvm.sh
mkdir -p tmp
touch tmp/emptyfile

View File

@@ -0,0 +1,62 @@
#!/bin/sh
cleanup () {
unset -f die
}
die () { echo -e "$@" ; cleanup ; exit 1; }
if type "clang" > /dev/null 2>&1 ; then
clang_exec="$(type "clang")"
sudo rm -rf "${clang_exec}"
fi
if type "clang++" > /dev/null 2>&1 ; then
clangxx_exec="$(type "clang++")"
sudo rm -rf "${clangxx_exec}"
fi
NVM_ENV=testing \. ../../../nvm.sh
clang() {
if [ "$1" = "--version" ]; then
echo "${VERSION_MESSAGE}"
fi
}
assert_version_is() {
if [ "${1}" != "${2}" ]; then
die "Expected ${2}, got ${1}, origin version message:\n${VERSION_MESSAGE}"
return 1
fi
}
CLANG_VERSION_ON_DEBIAN_JESSIE="Debian clang version 3.5.0-10 (tags/RELEASE_350/final) (based on LLVM 3.5.0)
Target: x86_64-pc-linux-gnu
Thread model: posix"
CLANG_VERSION_ON_UBUNTU_TRUSTY="Ubuntu clang version 3.4-1ubuntu3 (tags/RELEASE_34/final) (based on LLVM 3.4)
Target: x86_64-pc-linux-gnu
Thread model: posix"
CLANG_VERSION_ON_ARCHLINUX="clang version 3.9.0 (tags/RELEASE_390/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/sbin"
CLANG_VERSION_ON_FREEBSD="FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512
Target: x86_64-unknown-freebsd10.3
Thread model: posix"
VERSION_MESSAGE="${CLANG_VERSION_ON_DEBIAN_JESSIE}"
assert_version_is "$(nvm_clang_version)" "3.5.0"
VERSION_MESSAGE="${CLANG_VERSION_ON_UBUNTU_TRUSTY}"
assert_version_is "$(nvm_clang_version)" "3.4"
VERSION_MESSAGE="${CLANG_VERSION_ON_ARCHLINUX}"
assert_version_is "$(nvm_clang_version)" "3.9.0"
VERSION_MESSAGE="${CLANG_VERSION_ON_FREEBSD}"
assert_version_is "$(nvm_clang_version)" "3.4.1"
cleanup

View File

@@ -3,9 +3,9 @@
cleanup () {
unset -f nvm_compute_checksum
}
die () { echo $@ ; cleanup ; exit 1; }
die () { echo "$@" ; cleanup ; exit 1; }
. ../../../nvm.sh
\. ../../../nvm.sh
set -ex

View File

@@ -2,9 +2,9 @@
set -ex
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
. ../../../nvm.sh
\. ../../../nvm.sh
set +x
OUTPUT="$(nvm_compute_checksum 2>&1 >/dev/null || echo)"

View File

@@ -5,9 +5,9 @@ cleanup () {
alias npm='\npm'
unset -f nvm_has npm
}
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
. ../../../nvm.sh
\. ../../../nvm.sh
OUTPUT="$(nvm_die_on_prefix 2>&1)"
EXPECTED_OUTPUT="First argument \"delete the prefix\" must be zero or one"

View File

@@ -1,10 +1,10 @@
#!/bin/sh
. ../../common.sh
\. ../../common.sh
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
. ../../../nvm.sh
\. ../../../nvm.sh
EXPECTED_OUTPUT="nvm_ensure_default_set: a version is required"
OUTPUT="$(nvm_ensure_default_set 2>&1 >/dev/null)"

View File

@@ -1,11 +1,11 @@
#!/bin/sh
die () { echo $@ ; cleanup ; exit 1; }
die () { echo "$@" ; cleanup ; exit 1; }
cleanup () {
rm -rf "$(nvm_version_path v0.1.2)"
}
. ../../../nvm.sh
\. ../../../nvm.sh
mkdir -p "$(nvm_version_path v0.1.2)"

View File

@@ -1,8 +1,8 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
. ../../../nvm.sh
\. ../../../nvm.sh
[ "_$(nvm_ensure_version_prefix 1)" = "_v1" ] || die '"nvm_ensure_version_prefix 1" did not return "v1"'
[ "_$(nvm_ensure_version_prefix v1)" = "_v1" ] || die '"nvm_ensure_version_prefix v1" did not return "v1"'

View File

@@ -1,6 +1,6 @@
#!/bin/sh
die () { echo $@ ; cleanup ; exit 1; }
die () { echo "$@" ; cleanup ; exit 1; }
setup() {
cleanup
mkdir -p tmp_nvm_find_up/a/b/c/d
@@ -11,7 +11,7 @@ cleanup () {
rm -rf tmp_nvm_find_up
}
. ../../../nvm.sh
\. ../../../nvm.sh
setup

View File

@@ -1,8 +1,8 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
. ../../../nvm.sh
\. ../../../nvm.sh
INPUT="0.1.2"
OUTPUT="$(nvm_format_version "$INPUT")"

View File

@@ -9,9 +9,9 @@ cleanup() {
export PATH=ORIG_PATH
}
die () { cleanup; echo $@ ; exit 1; }
die () { cleanup; echo "$@" ; exit 1; }
. ../../../nvm.sh
\. ../../../nvm.sh
# Directory where mocked binaries used by nvm_get_arch for each OS/arch are
# located

View File

@@ -5,10 +5,10 @@ set -ex
cleanup () {
unset -f nvm_download nvm_get_checksum_alg nvm_get_mirror
}
die () { echo $@ ; cleanup ; exit 1; }
die () { echo "$@" ; cleanup ; exit 1; }
set +e # TODO: fix
. ../../../nvm.sh
\. ../../../nvm.sh
set -e
nvm_get_mirror() {

View File

@@ -2,9 +2,9 @@
set -ex
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
. ../../../nvm.sh
\. ../../../nvm.sh
ALG="$(nvm_get_checksum_alg)"

View File

@@ -1,12 +1,12 @@
#!/bin/sh
die () { echo $@ ; cleanup ; exit 1; }
die () { echo "$@" ; cleanup ; exit 1; }
cleanup() {
unset -f nvm_has
}
. ../../../nvm.sh
\. ../../../nvm.sh
nvm_has() { return 1 ; }

View File

@@ -1,8 +1,8 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
. ../../../nvm.sh
\. ../../../nvm.sh
expect () {
INPUT="$1"

View File

@@ -2,9 +2,9 @@
set -ex
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
. ../../../nvm.sh
\. ../../../nvm.sh
! nvm_get_mirror || die 'unknown release type did not error'
! nvm_get_mirror node || die 'unknown release type did not error'

View File

@@ -1,8 +1,8 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
. ../../../nvm.sh
\. ../../../nvm.sh
nvm_has cat && type cat > /dev/null || die 'nvm_has locates "cat" properly'

View File

@@ -1,9 +1,9 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
. ../../../nvm.sh
. ../../common.sh
\. ../../../nvm.sh
\. ../../common.sh
# Invalid version numbers fail
assert_not_ok nvm_has_solaris_binary ""

View File

@@ -5,9 +5,9 @@ cleanup () {
rm "${NVM_DIR}/versions/io.js/v0.1.2/iojs"
rmdir "${NVM_DIR}/versions/io.js/v0.1.2"
}
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
. ../../../nvm.sh
\. ../../../nvm.sh
mkdir "${NVM_DIR}/versions/io.js/v0.1.2"
touch "${NVM_DIR}/versions/io.js/v0.1.2/node"

View File

@@ -1,11 +1,11 @@
#!/bin/sh
. ../../../nvm.sh
\. ../../../nvm.sh
cleanup () {
rm -rf "${NVM_DIR}/v0.1.2/node"
}
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
mkdir "${NVM_DIR}/v0.1.2"
touch "${NVM_DIR}/v0.1.2/node"

View File

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

View File

@@ -1,9 +1,9 @@
#!/bin/sh
cleanup () { unalias foo; unalias grep; }
die () { echo $@ ; cleanup ; exit 1; }
die () { echo "$@" ; cleanup ; exit 1; }
. ../../../nvm.sh
\. ../../../nvm.sh
alias foo='bar'
nvm_is_alias foo || die '"nvm_is_alias foo" was not true'

View File

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

View File

@@ -1,8 +1,8 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
. ../../../nvm.sh
\. ../../../nvm.sh
nvm_is_merged_node_version '4.0' || die '"nvm_is_merged_node_version 4.0 was not true'
nvm_is_merged_node_version '5.1' || die '"nvm_is_merged_node_version 5.1 was not true'

View File

@@ -1,8 +1,8 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
. ../../../nvm.sh
\. ../../../nvm.sh
! nvm_is_natural_num || die 'no args is not false'
! nvm_is_natural_num '' || die 'empty string is not false'

View File

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

View File

@@ -4,9 +4,9 @@ TEST_PWD=$(pwd)
TEST_DIR="$TEST_PWD/nvm_ls_current_tmp"
cleanup() { rm -rf "$TEST_DIR"; unset -f return_zero; alias node='node' ; unalias node; }
die () { echo $@ ; cleanup ; exit 1; }
die () { echo "$@" ; cleanup ; exit 1; }
. ../../../nvm.sh
\. ../../../nvm.sh
return_zero () { return 0; }

View File

@@ -1,12 +1,12 @@
#!/bin/sh
die () { echo $@ ; cleanup ; exit 1; }
die () { echo "$@" ; cleanup ; exit 1; }
cleanup() {
unset -f nvm_download
}
. ../../../nvm.sh
\. ../../../nvm.sh
MOCKS_DIR="$PWD/mocks"

View File

@@ -1,6 +1,6 @@
#!/bin/sh
die () { echo $@ ; cleanup ; exit 1; }
die () { echo "$@" ; cleanup ; exit 1; }
TEST_PATH="$PWD/test_output"
mkdir -p "$TEST_PATH"
@@ -14,7 +14,7 @@ cleanup() {
rm -rf "$TEST_PATH"
}
. ../../../nvm.sh
\. ../../../nvm.sh
set -ex

View File

@@ -1,12 +1,12 @@
#!/bin/sh
die () { echo $@ ; cleanup ; exit 1; }
die () { echo "$@" ; cleanup ; exit 1; }
cleanup() {
unset -f nvm_download
}
. ../../../nvm.sh
\. ../../../nvm.sh
# sample output at the time the test was written
TAB_PATH="$PWD/mocks/iojs.org-dist-index.tab"

View File

@@ -1,8 +1,8 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
. ../../../nvm.sh
\. ../../../nvm.sh
OUTPUT="$(nvm_make_alias 2>&1)"
EXIT_CODE="$(nvm_make_alias >/dev/null 2>&1 ; echo $?)"

View File

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

View File

@@ -1,8 +1,8 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
. ../../../nvm.sh
\. ../../../nvm.sh
[ "~$(nvm_num_version_groups)" = "~0" ] || die "no args should give 0"
[ "~$(nvm_num_version_groups v)" = "~0" ] || die "just "v" should give 0"

View File

@@ -1,8 +1,8 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
. ../../../nvm.sh
\. ../../../nvm.sh
TEST_PATH=/usr/bin:/usr/local/bin

View File

@@ -1,13 +1,13 @@
#!/bin/sh
. ../../common.sh
\. ../../common.sh
die () { echo $@ ; cleanup ; exit 1; }
die () { echo "$@" ; cleanup ; exit 1; }
cleanup () {
unset -f nvm_alias nvm_version
}
. ../../../nvm.sh
\. ../../../nvm.sh
NVM_ALIAS_DIR='path/to/the alias/dir'

View File

@@ -1,13 +1,13 @@
#!/bin/sh
. ../../common.sh
\. ../../common.sh
die () { echo $@ ; cleanup ; exit 1; }
die () { echo "$@" ; cleanup ; exit 1; }
cleanup () {
unset -f nvm_print_implicit_alias nvm_version
}
. ../../../nvm.sh
\. ../../../nvm.sh
nvm_print_implicit_alias() {
echo ''

View File

@@ -1,8 +1,8 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
. ../../../nvm.sh
\. ../../../nvm.sh
EXPECTED_FIRST_MSG="nvm_print_implicit_alias must be specified with local or remote as the first argument."
[ "_$(nvm_print_implicit_alias 2>&1)" = "_$EXPECTED_FIRST_MSG" ] \

View File

@@ -1,6 +1,6 @@
#!/bin/sh
die () { echo $@ ; cleanup ; exit 1; }
die () { echo "$@" ; cleanup ; exit 1; }
cleanup() {
rm -rf "${NVM_DIR}/v0.2.3"
rm -rf "${NVM_DIR}/v0.3.4"
@@ -13,7 +13,7 @@ cleanup() {
unset -f nvm_ls_remote nvm_ls_remote_iojs
}
. ../../../nvm.sh
\. ../../../nvm.sh
mkdir "${NVM_DIR}/v0.2.3"
mkdir "${NVM_DIR}/v0.3.4"

View File

@@ -5,9 +5,9 @@ cleanup () {
alias npm='\npm'
unset -f nvm_has npm
}
die () { echo $@ ; exit 1; }
die () { echo "$@" ; exit 1; }
. ../../../nvm.sh
\. ../../../nvm.sh
nvm_has() { return 1; }
OUTPUT="$(nvm_print_npm_version)"

View File

@@ -1,12 +1,12 @@
#!/bin/sh
die () { echo $@ ; cleanup ; exit 1; }
die () { echo "$@" ; cleanup ; exit 1; }
cleanup() {
unset -f nvm_ls_remote nvm_ls_remote_iojs
}
. ../../../nvm.sh
\. ../../../nvm.sh
nvm_ls_remote() {
echo "N/A"

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