Compare commits
36 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65f0572bdc | ||
|
|
b6a7a54d04 | ||
|
|
8a8dcbb393 | ||
|
|
bacdd95591 | ||
|
|
4b0563093c | ||
|
|
c7ac69bfbb | ||
|
|
a57fe846e8 | ||
|
|
7bfd1e0644 | ||
|
|
9352f6913a | ||
|
|
16d3e6d2dc | ||
|
|
91a29c0da2 | ||
|
|
4b48556e92 | ||
|
|
be171bba33 | ||
|
|
049a86022f | ||
|
|
a7b7eec0c5 | ||
|
|
9953a52afb | ||
|
|
fc30e0ade4 | ||
|
|
b546436113 | ||
|
|
016bc134d5 | ||
|
|
9c25a8f316 | ||
|
|
a954458829 | ||
|
|
09951b49c5 | ||
|
|
3b133fac2f | ||
|
|
6ac8ebafba | ||
|
|
62fb0d0ad6 | ||
|
|
a461a0fffc | ||
|
|
6597e11971 | ||
|
|
707d268a76 | ||
|
|
73ad812215 | ||
|
|
8c578b864d | ||
|
|
d535c97d0f | ||
|
|
334897ae39 | ||
|
|
7b8af94fc9 | ||
|
|
7753b24948 | ||
|
|
44ab611421 | ||
|
|
c0b56d03a1 |
6
.gitignore
vendored
6
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
# gitignore
|
||||
HEAD
|
||||
.cache
|
||||
v*
|
||||
@@ -15,3 +16,8 @@ npm-debug.log
|
||||
.DS_Store
|
||||
current
|
||||
default-packages
|
||||
|
||||
# Only apps should have lockfiles
|
||||
npm-shrinkwrap.json
|
||||
package-lock.json
|
||||
yarn.lock
|
||||
|
||||
@@ -4,8 +4,6 @@ sudo: required
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- cabal-install
|
||||
- ghc
|
||||
- zsh
|
||||
# - ksh
|
||||
# - gcc-4.8
|
||||
@@ -14,8 +12,6 @@ addons:
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.npm
|
||||
- $HOME/.ghc
|
||||
- $HOME/.cabal
|
||||
- $TRAVIS_BUILD_DIR/.cache
|
||||
- $TRAVIS_BUILD_DIR/node_modules
|
||||
before_install:
|
||||
@@ -23,7 +19,6 @@ before_install:
|
||||
- curl --version
|
||||
- wget --version
|
||||
install:
|
||||
- if [ -n "${SHELLCHECK-}" ]; then cabal update && cabal install ShellCheck && shellcheck --version ; fi
|
||||
- if [ -z "${SHELLCHECK-}" ]; then nvm install node && npm install && npm prune && npm ls urchin doctoc; fi
|
||||
- '[ -z "$WITHOUT_CURL" ] || sudo apt-get remove curl -y'
|
||||
script:
|
||||
@@ -31,14 +26,14 @@ script:
|
||||
- if [ -n "${DOCTOCCHECK-}" ]; then cp README.md README.md.orig && npm run doctoc && diff -q README.md README.md.orig ; 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 [ -n "${SHELL-}" ] && [ -n "${TEST_SUITE}" ]; then make TEST_SUITE=$TEST_SUITE URCHIN="$(npm bin)/urchin" test-$SHELL ; fi
|
||||
- if [ -n "${SHELL-}" ] && [ -n "${TEST_SUITE}" ]; then if [ "${TEST_SUITE}" = 'installation_iojs' ]; then travis_retry make TEST_SUITE=$TEST_SUITE URCHIN="$(npm bin)/urchin" test-$SHELL ; else make TEST_SUITE=$TEST_SUITE URCHIN="$(npm bin)/urchin" test-$SHELL; fi; fi
|
||||
before_cache:
|
||||
- if [ -n "$WITHOUT_CURL" ]; then sudo apt-get install curl -y ; fi
|
||||
env:
|
||||
global:
|
||||
- CXX=g++-4.8
|
||||
- CC=gcc-4.8
|
||||
- PATH="~/.cabal/bin/:$(echo $PATH | sed 's/::/:/')"
|
||||
- PATH="$(echo $PATH | sed 's/::/:/')"
|
||||
- NVM_DIR="${TRAVIS_BUILD_DIR}"
|
||||
matrix:
|
||||
- MAKE_RELEASE=true
|
||||
|
||||
26
README.md
26
README.md
@@ -1,4 +1,4 @@
|
||||
# Node Version Manager [][3] [][4] [](https://bestpractices.coreinfrastructure.org/projects/684)
|
||||
# Node Version Manager [][3] [][4] [](https://bestpractices.coreinfrastructure.org/projects/684)
|
||||
|
||||
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
||||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
||||
@@ -41,13 +41,13 @@
|
||||
To install or update nvm, you can use the [install script][2] using cURL:
|
||||
|
||||
```sh
|
||||
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.4/install.sh | bash
|
||||
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.7/install.sh | bash
|
||||
```
|
||||
|
||||
or Wget:
|
||||
|
||||
```sh
|
||||
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.4/install.sh | bash
|
||||
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.7/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>
|
||||
@@ -127,8 +127,8 @@ If you have `git` installed (requires git v1.7+):
|
||||
|
||||
1. clone this repo in the root of your user profile
|
||||
- `cd ~/` from anywhere then `git clone https://github.com/creationix/nvm.git .nvm`
|
||||
1. check out the latest version with `git checkout v0.33.4`
|
||||
1. activate nvm by sourcing it from your shell
|
||||
2. `cd ~/.nvm` and check out the latest version with `git checkout v0.33.7`
|
||||
3. activate nvm by sourcing it from your shell: `. nvm.sh`
|
||||
|
||||
Now add these lines to your `~/.bashrc`, `~/.profile`, or `~/.zshrc` file to have it automatically sourced upon login:
|
||||
(you may have to add to more than one of the above files)
|
||||
@@ -325,7 +325,7 @@ NVM_IOJS_ORG_MIRROR=https://iojs.org/dist nvm install iojs-v1.0.3
|
||||
### .nvmrc
|
||||
|
||||
You can create a `.nvmrc` file containing version number in the project root directory (or any parent directory).
|
||||
`nvm use`, `nvm install`, `nvm exec`, `nvm run`, and `nvm which` will all respect an `.nvmrc` file when a version is not supplied.
|
||||
`nvm use`, `nvm install`, `nvm exec`, `nvm run`, and `nvm which` will all respect an `.nvmrc` file when a version is not supplied on the command line.
|
||||
|
||||
For example, to make nvm default to the latest 5.9 release for the current directory:
|
||||
|
||||
@@ -486,8 +486,8 @@ There is a `-s` flag for `nvm install` which requests nvm download Node source a
|
||||
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 -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.4/install.sh | bash
|
||||
apk add -U curl bash ca-certificates openssl ncurses coreutils python2 make gcc g++ libgcc linux-headers grep util-linux binutils findutils
|
||||
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.7/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.
|
||||
@@ -519,7 +519,7 @@ $ docker run -it nvm-dev -h nvm-dev
|
||||
nvm@nvm-dev:~/.nvm$
|
||||
```
|
||||
|
||||
Please note that it'll take about 15 minutes to build the image and the image size would be about 1.2GB, so it's not sutable for production usage.
|
||||
Please note that it'll take about 15 minutes to build the image and the image size would be about 1.2GB, so it's not suitable for production usage.
|
||||
|
||||
For more information and documentation about docker, please refer to its official website:
|
||||
- https://www.docker.com/
|
||||
@@ -527,7 +527,7 @@ For more information and documentation about docker, please refer to its officia
|
||||
|
||||
## 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:
|
||||
- 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.
|
||||
|
||||
@@ -539,7 +539,7 @@ For more information and documentation about docker, please refer to its officia
|
||||
nvm install -s 0.8.6
|
||||
```
|
||||
|
||||
- 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))
|
||||
- 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))
|
||||
|
||||
## Mac OS "troubleshooting"
|
||||
|
||||
@@ -554,8 +554,8 @@ sudo chmod ugo-x /usr/libexec/path_helper
|
||||
More on this issue in [dotphiles/dotzsh](https://github.com/dotphiles/dotzsh#mac-os-x).
|
||||
|
||||
[1]: https://github.com/creationix/nvm.git
|
||||
[2]: https://github.com/creationix/nvm/blob/v0.33.4/install.sh
|
||||
[2]: https://github.com/creationix/nvm/blob/v0.33.7/install.sh
|
||||
[3]: https://travis-ci.org/creationix/nvm
|
||||
[4]: https://github.com/creationix/nvm/releases/tag/v0.33.4
|
||||
[4]: https://github.com/creationix/nvm/releases/tag/v0.33.7
|
||||
[Urchin]: https://github.com/scraperwiki/urchin
|
||||
[Fish]: http://fishshell.com
|
||||
|
||||
25
install.sh
25
install.sh
@@ -11,7 +11,7 @@ nvm_install_dir() {
|
||||
}
|
||||
|
||||
nvm_latest_version() {
|
||||
echo "v0.33.4"
|
||||
echo "v0.33.7"
|
||||
}
|
||||
|
||||
nvm_profile_is_bash_or_zsh() {
|
||||
@@ -140,22 +140,22 @@ install_nvm_from_git() {
|
||||
# Automatically install Node.js
|
||||
#
|
||||
nvm_install_node() {
|
||||
local NODE_VERSION
|
||||
NODE_VERSION="$(nvm_node_version)"
|
||||
local NODE_VERSION_LOCAL
|
||||
NODE_VERSION_LOCAL="$(nvm_node_version)"
|
||||
|
||||
if [ -z "$NODE_VERSION" ]; then
|
||||
if [ -z "$NODE_VERSION_LOCAL" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "=> Installing Node.js version $NODE_VERSION"
|
||||
nvm install "$NODE_VERSION"
|
||||
echo "=> Installing Node.js version $NODE_VERSION_LOCAL"
|
||||
nvm install "$NODE_VERSION_LOCAL"
|
||||
local CURRENT_NVM_NODE
|
||||
|
||||
CURRENT_NVM_NODE="$(nvm_version current)"
|
||||
if [ "$(nvm_version "$NODE_VERSION")" == "$CURRENT_NVM_NODE" ]; then
|
||||
echo "=> Node.js version $NODE_VERSION has been successfully installed"
|
||||
if [ "$(nvm_version "$NODE_VERSION_LOCAL")" == "$CURRENT_NVM_NODE" ]; then
|
||||
echo "=> Node.js version $NODE_VERSION_LOCAL has been successfully installed"
|
||||
else
|
||||
echo >&2 "Failed to install Node.js $NODE_VERSION"
|
||||
echo >&2 "Failed to install Node.js $NODE_VERSION_LOCAL"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -330,9 +330,12 @@ nvm_do_install() {
|
||||
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."
|
||||
local TRIED_PROFILE
|
||||
if [ -n "${PROFILE}" ]; then
|
||||
TRIED_PROFILE="${NVM_PROFILE} (as defined in \$PROFILE), "
|
||||
fi
|
||||
echo "=> Profile not found. Tried ${TRIED_PROFILE-}~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile."
|
||||
echo "=> Create one of them and run this script again"
|
||||
echo "=> Create it (touch ${NVM_PROFILE}) and run this script again"
|
||||
echo " OR"
|
||||
echo "=> Append the following lines to the correct file yourself:"
|
||||
command printf "${SOURCE_STR}"
|
||||
|
||||
97
nvm.sh
97
nvm.sh
@@ -13,13 +13,7 @@
|
||||
NVM_SCRIPT_SOURCE="$_"
|
||||
|
||||
nvm_echo() {
|
||||
command printf %s\\n "$*" 2>/dev/null || {
|
||||
nvm_echo() {
|
||||
# shellcheck disable=SC1001
|
||||
\printf %s\\n "$*" # on zsh, `command printf` sometimes fails
|
||||
}
|
||||
nvm_echo "$@"
|
||||
}
|
||||
command printf %s\\n "$*" 2>/dev/null
|
||||
}
|
||||
|
||||
nvm_cd() {
|
||||
@@ -53,13 +47,13 @@ nvm_command_info() {
|
||||
local COMMAND
|
||||
local INFO
|
||||
COMMAND="${1}"
|
||||
if type "${COMMAND}" | command grep -q hashed; then
|
||||
if type "${COMMAND}" | nvm_grep -q hashed; then
|
||||
INFO="$(type "${COMMAND}" | command sed -E 's/\(|)//g' | command awk '{print $4}')"
|
||||
elif type "${COMMAND}" | command grep -q aliased; then
|
||||
elif type "${COMMAND}" | nvm_grep -q aliased; then
|
||||
INFO="$(which "${COMMAND}") ($(type "${COMMAND}" | command awk '{ $1=$2=$3=$4="" ;print }' | command sed -e 's/^\ *//g' -Ee "s/\`|'//g" ))"
|
||||
elif type "${COMMAND}" | command grep -q "^${COMMAND} is an alias for"; then
|
||||
elif type "${COMMAND}" | nvm_grep -q "^${COMMAND} is an alias for"; then
|
||||
INFO="$(which "${COMMAND}") ($(type "${COMMAND}" | command awk '{ $1=$2=$3=$4=$5="" ;print }' | command sed 's/^\ *//g'))"
|
||||
elif type "${COMMAND}" | command grep -q "^${COMMAND} is \/"; then
|
||||
elif type "${COMMAND}" | nvm_grep -q "^${COMMAND} is \/"; then
|
||||
INFO="$(type "${COMMAND}" | command awk '{print $3}')"
|
||||
else
|
||||
INFO="$(type "${COMMAND}")"
|
||||
@@ -199,19 +193,28 @@ nvm_install_latest_npm() {
|
||||
|
||||
if [ $NVM_IS_0_9 -eq 1 ] || [ $NVM_IS_0_6 -eq 1 ]; then
|
||||
nvm_echo '* node v0.6 and v0.9 are unable to upgrade further'
|
||||
elif nvm_version_greater_than_or_equal_to 1.0.0 "${NODE_VERSION}"; then
|
||||
nvm_echo '* `npm` v4.5.x is the last version that works on `node` versions <= v1.0.0'
|
||||
elif nvm_version_greater 1.1.0 "${NODE_VERSION}"; then
|
||||
nvm_echo '* `npm` v4.5.x is the last version that works on `node` versions < v1.1.0'
|
||||
$NVM_NPM_CMD install -g npm@4.5
|
||||
elif nvm_version_greater 4.0.0 "${NODE_VERSION}"; then
|
||||
nvm_echo '* `npm` v5 and higher do not work on `node` versions below v4.0.0'
|
||||
$NVM_NPM_CMD install -g npm@4
|
||||
elif [ $NVM_IS_0_9 -eq 0 ] && [ $NVM_IS_0_6 -eq 0 ]; then
|
||||
if nvm_version_greater 4.5.0 "${NODE_VERSION}" || (\
|
||||
local NVM_IS_4_4_OR_BELOW
|
||||
NVM_IS_4_4_OR_BELOW=0
|
||||
if nvm_version_greater 4.5.0 "${NODE_VERSION}"; then
|
||||
NVM_IS_4_4_OR_BELOW=1
|
||||
fi
|
||||
|
||||
if [ $NVM_IS_4_4_OR_BELOW -eq 1 ] || (\
|
||||
nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 5.0.0 \
|
||||
&& nvm_version_greater 5.10.0 "${NODE_VERSION}"\
|
||||
); then
|
||||
nvm_echo '* `npm` `v5.3.x` is the last version that works on `node` 4.x versions below v4.4, or 5.x versions below v5.10, due to `Buffer.alloc`'
|
||||
$NVM_NPM_CMD install -g npm@5.3
|
||||
elif $NVM_IS_4_4_OR_BELOW -eq 0 && nvm_version_greater 4.7.0 "${NODE_VERSION}"; then
|
||||
nvm_echo '* `npm` `v5.4.x` is the last version that works on `node` `v4.5` and `v4.6`'
|
||||
$NVM_NPM_CMD install -g npm@5.4
|
||||
else
|
||||
nvm_echo '* Installing latest `npm`; if this does not work on your node version, please report a bug!'
|
||||
$NVM_NPM_CMD install -g npm
|
||||
@@ -264,12 +267,12 @@ nvm_tree_contains_path() {
|
||||
|
||||
# Traverse up in directory tree to find containing folder
|
||||
nvm_find_up() {
|
||||
local path
|
||||
path="${PWD}"
|
||||
while [ "${path}" != "" ] && [ ! -f "${path}/${1-}" ]; do
|
||||
path=${path%/*}
|
||||
local path_
|
||||
path_="${PWD}"
|
||||
while [ "${path_}" != "" ] && [ ! -f "${path_}/${1-}" ]; do
|
||||
path_=${path_%/*}
|
||||
done
|
||||
nvm_echo "${path}"
|
||||
nvm_echo "${path_}"
|
||||
}
|
||||
|
||||
|
||||
@@ -505,6 +508,7 @@ nvm_remote_versions() {
|
||||
local NVM_LS_REMOTE_IOJS_EXIT_CODE
|
||||
NVM_LS_REMOTE_IOJS_EXIT_CODE=0
|
||||
local NVM_LS_REMOTE_IOJS_OUTPUT
|
||||
NVM_LS_REMOTE_IOJS_OUTPUT=''
|
||||
if [ -z "${NVM_LTS-}" ] && ( \
|
||||
[ -z "${NVM_FLAVOR-}" ] || [ "${NVM_FLAVOR-}" = "${NVM_IOJS_PREFIX}" ] \
|
||||
); then
|
||||
@@ -601,11 +605,21 @@ nvm_strip_path() {
|
||||
-e "s#${NVM_DIR}/versions/[^/]*/[^/]*${2-}[^:]*##g"
|
||||
}
|
||||
|
||||
nvm_prepend_path() {
|
||||
nvm_change_path() {
|
||||
# if there’s no initial path, just return the supplementary path
|
||||
if [ -z "${1-}" ]; then
|
||||
nvm_echo "${2-}"
|
||||
nvm_echo "${3-}${2-}"
|
||||
# if the initial path doesn’t contain an nvm path, prepend the supplementary
|
||||
# path
|
||||
elif ! echo "${1-}" | nvm_grep -q "${NVM_DIR}/[^/]*${2-}" && \
|
||||
! echo "${1-}" | nvm_grep -q "${NVM_DIR}/versions/[^/]*/[^/]*${2-}"; then
|
||||
nvm_echo "${3-}${2-}:${1-}"
|
||||
# use sed to replace the existing nvm path with the supplementary path. This
|
||||
# preserves the order of the path.
|
||||
else
|
||||
nvm_echo "${2-}:${1-}"
|
||||
nvm_echo "${1-}" | command sed \
|
||||
-e "s#${NVM_DIR}/[^/]*${2-}[^:]*#${3-}${2-}#g" \
|
||||
-e "s#${NVM_DIR}/versions/[^/]*/[^/]*${2-}[^:]*#${3-}${2-}#g"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -2344,9 +2358,9 @@ nvm() {
|
||||
local DIR
|
||||
DIR="$(nvm_cache_dir)"
|
||||
if command rm -rf "${DIR}" && command mkdir -p "${DIR}"; then
|
||||
nvm_echo 'Cache cleared.'
|
||||
nvm_echo 'nvm cache cleared.'
|
||||
else
|
||||
nvm_err "Unable to clear cache: ${DIR}"
|
||||
nvm_err "Unable to clear nvm cache: ${DIR}"
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
@@ -2392,11 +2406,15 @@ nvm() {
|
||||
else
|
||||
nvm_err "wget: not found"
|
||||
fi
|
||||
if nvm_has "git"; then
|
||||
nvm_err "git: $(nvm_command_info git), $(command git --version)"
|
||||
else
|
||||
nvm_err "git: not found"
|
||||
fi
|
||||
|
||||
for tool in git grep awk sed cut basename rm mkdir xargs; do
|
||||
if nvm_has "${tool}"; then
|
||||
nvm_err "${tool}: $(nvm_command_info ${tool}), $(command ${tool} --version | command head -n 1)"
|
||||
else
|
||||
nvm_err "${tool}: not found"
|
||||
fi
|
||||
done
|
||||
|
||||
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
|
||||
@@ -2866,19 +2884,15 @@ nvm() {
|
||||
local NVM_VERSION_DIR
|
||||
NVM_VERSION_DIR="$(nvm_version_path "$VERSION")"
|
||||
|
||||
# Strip other version from PATH
|
||||
PATH="$(nvm_strip_path "$PATH" "/bin")"
|
||||
# Prepend current version
|
||||
PATH="$(nvm_prepend_path "$PATH" "$NVM_VERSION_DIR/bin")"
|
||||
# Change current version
|
||||
PATH="$(nvm_change_path "$PATH" "/bin" "$NVM_VERSION_DIR")"
|
||||
if nvm_has manpath; then
|
||||
if [ -z "${MANPATH-}" ]; then
|
||||
local MANPATH
|
||||
MANPATH=$(manpath)
|
||||
fi
|
||||
# Strip other version from MANPATH
|
||||
MANPATH="$(nvm_strip_path "$MANPATH" "/share/man")"
|
||||
# Prepend current version
|
||||
MANPATH="$(nvm_prepend_path "$MANPATH" "$NVM_VERSION_DIR/share/man")"
|
||||
# Change current version
|
||||
MANPATH="$(nvm_change_path "$MANPATH" "/share/man" "$NVM_VERSION_DIR")"
|
||||
export MANPATH
|
||||
fi
|
||||
export PATH
|
||||
@@ -2888,6 +2902,7 @@ nvm() {
|
||||
command rm -f "$NVM_DIR/current" && ln -s "$NVM_VERSION_DIR" "$NVM_DIR/current"
|
||||
fi
|
||||
local NVM_USE_OUTPUT
|
||||
NVM_USE_OUTPUT=''
|
||||
if [ $NVM_USE_SILENT -ne 1 ]; then
|
||||
if nvm_is_iojs_version "$VERSION"; then
|
||||
NVM_USE_OUTPUT="Now using io.js $(nvm_strip_iojs_prefix "$VERSION")$(nvm_print_npm_version)"
|
||||
@@ -3327,7 +3342,7 @@ nvm() {
|
||||
;;
|
||||
"clear-cache" )
|
||||
command rm -f "$NVM_DIR/v*" "$(nvm_version_dir)" 2>/dev/null
|
||||
nvm_echo 'Cache cleared.'
|
||||
nvm_echo 'nvm cache cleared.'
|
||||
;;
|
||||
"version" )
|
||||
nvm_version "${1}"
|
||||
@@ -3368,7 +3383,7 @@ nvm() {
|
||||
NVM_VERSION_ONLY=true NVM_LTS="${NVM_LTS-}" nvm_remote_version "${PATTERN:-node}"
|
||||
;;
|
||||
"--version" )
|
||||
nvm_echo '0.33.4'
|
||||
nvm_echo '0.33.7'
|
||||
;;
|
||||
"unload" )
|
||||
nvm deactivate >/dev/null 2>&1
|
||||
@@ -3387,7 +3402,7 @@ nvm() {
|
||||
nvm_ensure_default_set nvm_get_arch nvm_get_os \
|
||||
nvm_print_implicit_alias nvm_validate_implicit_alias \
|
||||
nvm_resolve_alias nvm_ls_current nvm_alias \
|
||||
nvm_binary_available nvm_prepend_path nvm_strip_path \
|
||||
nvm_binary_available nvm_change_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_cache_dir \
|
||||
@@ -3408,7 +3423,7 @@ nvm() {
|
||||
node_version_has_solaris_binary iojs_version_has_solaris_binary \
|
||||
nvm_curl_libz_support nvm_command_info \
|
||||
> /dev/null 2>&1
|
||||
unset RC_VERSION NVM_NODEJS_ORG_MIRROR NVM_IOJS_ORG_MIRROR NVM_DIR \
|
||||
unset NVM_RC_VERSION NVM_NODEJS_ORG_MIRROR NVM_IOJS_ORG_MIRROR NVM_DIR \
|
||||
NVM_CD_FLAGS NVM_BIN NVM_MAKE_JOBS \
|
||||
> /dev/null 2>&1
|
||||
;;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "nvm",
|
||||
"version": "0.33.4",
|
||||
"version": "0.33.7",
|
||||
"description": "Node Version Manager - Simple bash script to manage multiple active node.js versions",
|
||||
"directories": {
|
||||
"test": "test"
|
||||
|
||||
@@ -6,17 +6,17 @@ mkdir -p ../../v0.2.3
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
[ `expr $PATH : ".*v0.2.3/.*/bin"` = 0 ] || echo "WARNING: Unexpectedly found v0.2.3 already active" >&2
|
||||
[ `expr $PATH : ".*v0.2.3/.*/bin.*"` = 0 ] || echo "WARNING: Unexpectedly found v0.2.3 already active" >&2
|
||||
|
||||
\. ../../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 "$PATH" : ".*v0.2.3/.*/bin.*"` != 0 ] || die "PATH not set up properly"
|
||||
[ `expr "$NODE_PATH" : ".*v0.2.3/.*/lib/node_modules.*"` = 0 ] || die "NODE_PATH should not contain (npm root -g)"
|
||||
# ^ note: NODE_PATH should not contain `npm root -g` since globals should not be requireable
|
||||
[ `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"
|
||||
[ `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'"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
set -eux
|
||||
|
||||
cleanup() {
|
||||
unset -f nvm_has_system_node nvm_print_npm_version
|
||||
|
||||
43
test/fast/Unit tests/nvm_change_path
Executable file
43
test/fast/Unit tests/nvm_change_path
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
TEST_PATH=/usr/bin:/usr/local/bin
|
||||
|
||||
# New version dir
|
||||
NEW_PATH=`nvm_change_path "$TEST_PATH" "/bin" "$NVM_DIR/versions/node/v7.1.0"`
|
||||
|
||||
[ "$NEW_PATH" = "$NVM_DIR/versions/node/v7.1.0/bin:/usr/bin:/usr/local/bin" ] || die "Not correctly changed: $NEW_PATH "
|
||||
|
||||
# Old version dir
|
||||
NEW_PATH=`nvm_change_path "$TEST_PATH" "/bin" "$NVM_DIR/v0.1.2"`
|
||||
|
||||
[ "$NEW_PATH" = "$NVM_DIR/v0.1.2/bin:/usr/bin:/usr/local/bin" ] || die "Not correctly changed: $NEW_PATH "
|
||||
|
||||
|
||||
TEST_PATH=/home/user/code/test/node_modules/.bin:$NVM_DIR/versions/node/v4.5.0/bin:/usr/bin:/usr/local/bin
|
||||
|
||||
# New version dir
|
||||
NEW_PATH=`nvm_change_path "$TEST_PATH" "/bin" "$NVM_DIR/versions/node/v7.1.0"`
|
||||
|
||||
[ "$NEW_PATH" = "/home/user/code/test/node_modules/.bin:$NVM_DIR/versions/node/v7.1.0/bin:/usr/bin:/usr/local/bin" ] || die "Not correctly changed: $NEW_PATH "
|
||||
|
||||
# Old version dir
|
||||
NEW_PATH=`nvm_change_path "$TEST_PATH" "/bin" "$NVM_DIR/v0.1.2"`
|
||||
|
||||
[ "$NEW_PATH" = "/home/user/code/test/node_modules/.bin:$NVM_DIR/v0.1.2/bin:/usr/bin:/usr/local/bin" ] || die "Not correctly changed: $NEW_PATH "
|
||||
|
||||
|
||||
EMPTY_PATH=
|
||||
|
||||
# New version dir
|
||||
NEW_PATH=`nvm_change_path "$EMPTY_PATH" "/bin" "$NVM_DIR/versions/node/v7.1.0"`
|
||||
|
||||
[ "$NEW_PATH" = "$NVM_DIR/versions/node/v7.1.0/bin" ] || die "Not correctly prepended: $NEW_PATH "
|
||||
|
||||
# Old version dir
|
||||
NEW_PATH=`nvm_change_path "$EMPTY_PATH" "/bin" "$NVM_DIR/v0.1.2"`
|
||||
|
||||
[ "$NEW_PATH" = "$NVM_DIR/v0.1.2/bin" ] || die "Not correctly prepended: $NEW_PATH "
|
||||
@@ -21,6 +21,7 @@ rm -rf "$TEST_DIR"
|
||||
mkdir "$TEST_DIR"
|
||||
ln -s "$(command which which)" "$TEST_DIR/which"
|
||||
ln -s "$(command which dirname)" "$TEST_DIR/dirname"
|
||||
ln -s "$(command which printf)" "$TEST_DIR/printf"
|
||||
|
||||
[ "$(PATH="$TEST_DIR" nvm_ls_current)" = "none" ] || die 'when node not installed, nvm_ls_current did not return "none"'
|
||||
[ "@$(PATH="$TEST_DIR" nvm_ls_current 2> /dev/stdout 1> /dev/null)@" = "@@" ] || die 'when node not installed, nvm_ls_current returned error output'
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
TEST_PATH=/usr/bin:/usr/local/bin
|
||||
|
||||
NEW_PATH=`nvm_prepend_path "$TEST_PATH" "$NVM_DIR/v0.2.5/bin"`
|
||||
|
||||
[ "$NEW_PATH" = "$NVM_DIR/v0.2.5/bin:/usr/bin:/usr/local/bin" ] || die "Not correctly prepended: $NEW_PATH "
|
||||
|
||||
|
||||
EMPTY_PATH=
|
||||
|
||||
NEW_PATH=`nvm_prepend_path "$EMPTY_PATH" "$NVM_DIR/v0.2.5/bin"`
|
||||
|
||||
[ "$NEW_PATH" = "$NVM_DIR/v0.2.5/bin" ] || die "Not correctly prepended: $NEW_PATH "
|
||||
8
test/install_script/nvm_install_with_node_version
Executable file
8
test/install_script/nvm_install_with_node_version
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
NODE_VERSION=8 \. ../../install.sh
|
||||
|
||||
# nvm installed node 8
|
||||
nvm ls 8 > /dev/null 2>&1 || die "nvm didn't install node 8"
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
set -eux
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
|
||||
@@ -15,20 +15,27 @@ NPM_VERSION="$(npm --version)"
|
||||
nvm_version_greater_than_or_equal_to "${NPM_VERSION}" 5.0.0 || die "node v4.x updates to ${NPM_VERSION}; expected >= v5"
|
||||
|
||||
nvm deactivate >/dev/null 2>&1 || die 'unable to deactivate: 2'
|
||||
nvm install 1 >/dev/null 2>&1 || die 'install v1 failed'
|
||||
nvm install 1.0 >/dev/null 2>&1 || die 'install v1.0 failed'
|
||||
nvm install-latest-npm || die 'nvm install-latest-npm failed: 2'
|
||||
NPM_VERSION="$(npm --version)"
|
||||
[ "${NPM_VERSION}" = '4.5.0' ] || die "io.js v1.0.x updates to ${NPM_VERSION}; expected v4.5.0"
|
||||
|
||||
nvm deactivate >/dev/null 2>&1 || die 'unable to deactivate: 3'
|
||||
nvm install 1 >/dev/null 2>&1 || die 'install v1 failed'
|
||||
nvm install-latest-npm || die 'nvm install-latest-npm failed: 3'
|
||||
NPM_VERSION="$(npm --version)"
|
||||
[ "${NPM_VERSION}" = '4.6.1' ] || die "io.js v1.x updates to ${NPM_VERSION}; expected v4.6.1"
|
||||
|
||||
nvm deactivate >/dev/null 2>&1 || die 'unable to deactivate: 3'
|
||||
nvm deactivate >/dev/null 2>&1 || die 'unable to deactivate: 4'
|
||||
nvm install 0.8.27 >/dev/null 2>&1 || die 'install v0.8 failed'
|
||||
nvm install-latest-npm || die 'nvm install-latest-npm failed: 3'
|
||||
nvm install-latest-npm || die 'nvm install-latest-npm failed: 4'
|
||||
NPM_VERSION="$(npm --version)"
|
||||
[ "${NPM_VERSION}" = '4.5.0' ] || die "node 0.8.27 updates to ${NPM_VERSION}; expected v4.5.0"
|
||||
|
||||
nvm deactivate >/dev/null 2>&1 || die 'unable to deactivate: 4'
|
||||
nvm install 0.6.21 >/dev/null 2>&1 || die 'install v0.6 failed'
|
||||
export NPM_CONFIG_STRICT_SSL=false # npm 1 on travis can't handle SSL to npm
|
||||
nvm install-latest-npm || die 'nvm install-latest-npm failed: 4'
|
||||
NPM_VERSION="$(npm --version)"
|
||||
[ "${NPM_VERSION}" = '1.3.26' ] || die "node 0.6.21 updates to ${NPM_VERSION}; expected v1.3.26"
|
||||
## Commented to work around travis-ci breaking 0,6 installs
|
||||
# nvm deactivate >/dev/null 2>&1 || die 'unable to deactivate: 5'
|
||||
# nvm install 0.6.21 >/dev/null 2>&1 || die 'install v0.6 failed'
|
||||
# export NPM_CONFIG_STRICT_SSL=false # npm 1 on travis can't handle SSL to npm
|
||||
# nvm install-latest-npm || die 'nvm install-latest-npm failed: 5'
|
||||
# NPM_VERSION="$(npm --version)"
|
||||
# [ "${NPM_VERSION}" = '1.3.26' ] || die "node 0.6.21 updates to ${NPM_VERSION}; expected v1.3.26"
|
||||
|
||||
Reference in New Issue
Block a user