Compare commits
67 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 | ||
|
|
d91b6197f3 | ||
|
|
e3d1519567 | ||
|
|
6f19babbff | ||
|
|
b3e25b15f9 | ||
|
|
cf5272e1a0 | ||
|
|
3e1b4591bd | ||
|
|
389a53cca9 | ||
|
|
248706d5f8 | ||
|
|
ab591b07ef | ||
|
|
38a568c9c9 | ||
|
|
b3bdbb2712 | ||
|
|
6921adb2f4 | ||
|
|
f37ddea78f | ||
|
|
1e69c4c77d | ||
|
|
3ac49e5ef1 | ||
|
|
0356839d05 | ||
|
|
b5034bb2b2 | ||
|
|
d073bc96c7 | ||
|
|
11370fe823 | ||
|
|
cbdd41eee2 | ||
|
|
28fe93cd15 | ||
|
|
7965796569 | ||
|
|
d2644b22f9 | ||
|
|
051ef09daf | ||
|
|
3497474fef | ||
|
|
c3c2d350e9 | ||
|
|
4f626eac0d | ||
|
|
7f3145bc98 | ||
|
|
dc5dfe3bc1 | ||
|
|
accd6ae298 | ||
|
|
caa7de37af |
17
.dockerignore
Normal file
17
.dockerignore
Normal file
@@ -0,0 +1,17 @@
|
||||
HEAD
|
||||
.cache
|
||||
v*
|
||||
alias
|
||||
|
||||
# For testing
|
||||
test/bak
|
||||
.urchin.log
|
||||
.urchin_stdout
|
||||
test/**/test_output
|
||||
|
||||
node_modules/
|
||||
npm-debug.log
|
||||
|
||||
.DS_Store
|
||||
current
|
||||
|
||||
7
.gitignore
vendored
7
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
# gitignore
|
||||
HEAD
|
||||
.cache
|
||||
v*
|
||||
@@ -14,3 +15,9 @@ npm-debug.log
|
||||
|
||||
.DS_Store
|
||||
current
|
||||
default-packages
|
||||
|
||||
# Only apps should have lockfiles
|
||||
npm-shrinkwrap.json
|
||||
package-lock.json
|
||||
yarn.lock
|
||||
|
||||
11
.travis.yml
11
.travis.yml
@@ -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
|
||||
after_success:
|
||||
- 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
|
||||
|
||||
105
Dockerfile
Normal file
105
Dockerfile
Normal file
@@ -0,0 +1,105 @@
|
||||
# Dockerized nvm development environment
|
||||
#
|
||||
# This Dockerfile is for building nvm development environment only,
|
||||
# not for any distribution/production usage.
|
||||
#
|
||||
# Please note that it'll use about 1.2 GB disk space and about 15 minutes to
|
||||
# build this image, it depends on your hardware.
|
||||
|
||||
# Use Ubuntu Trusty Tahr as base image as we're using on Travis CI
|
||||
# I also tested with Ubuntu 16.04, should be good with it!
|
||||
From ubuntu:14.04
|
||||
MAINTAINER Peter Dave Hello <hsu@peterdavehello.org>
|
||||
|
||||
# Prevent dialog during apt install
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
|
||||
# Pick a Ubuntu apt mirror site for better speed
|
||||
# ref: https://launchpad.net/ubuntu/+archivemirrors
|
||||
ENV UBUNTU_APT_SITE ubuntu.cs.utah.edu
|
||||
|
||||
# Disable src package source
|
||||
RUN sed -i 's/^deb-src\ /\#deb-src\ /g' /etc/apt/sources.list
|
||||
|
||||
# Replace origin apt pacakge site with the mirror site
|
||||
RUN sed -E -i "s/([a-z]+.)?archive.ubuntu.com/$UBUNTU_APT_SITE/g" /etc/apt/sources.list
|
||||
RUN sed -i "s/security.ubuntu.com/$UBUNTU_APT_SITE/g" /etc/apt/sources.list
|
||||
|
||||
# Install apt packages
|
||||
RUN apt update && \
|
||||
apt upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" && \
|
||||
apt install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \
|
||||
coreutils \
|
||||
util-linux \
|
||||
bsdutils \
|
||||
file \
|
||||
openssl \
|
||||
ca-certificates \
|
||||
ssh \
|
||||
wget \
|
||||
patch \
|
||||
sudo \
|
||||
htop \
|
||||
dstat \
|
||||
vim \
|
||||
tmux \
|
||||
curl \
|
||||
git \
|
||||
jq \
|
||||
realpath \
|
||||
zsh \
|
||||
ksh \
|
||||
ghc \
|
||||
gcc-4.8 \
|
||||
g++-4.8 \
|
||||
cabal-install \
|
||||
build-essential \
|
||||
bash-completion && \
|
||||
apt-get clean
|
||||
|
||||
# Set locale
|
||||
RUN locale-gen en_US.UTF-8
|
||||
|
||||
# Print tool versions
|
||||
RUN bash --version | head -n 1
|
||||
RUN zsh --version
|
||||
RUN ksh --version || true
|
||||
RUN dpkg -s dash | grep ^Version | awk '{print $2}'
|
||||
RUN git --version
|
||||
RUN curl --version
|
||||
RUN wget --version
|
||||
RUN cabal --version
|
||||
|
||||
# Add user "nvm" as non-root user
|
||||
RUN useradd -ms /bin/bash nvm
|
||||
|
||||
# Set sudoer for "nvm"
|
||||
RUN echo 'nvm ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
|
||||
|
||||
# Switch to user "nvm" from now
|
||||
USER nvm
|
||||
|
||||
# Shellcheck
|
||||
RUN cabal update
|
||||
RUN cabal install ShellCheck
|
||||
RUN ~/.cabal/bin/shellcheck --version
|
||||
RUN echo 'export PATH="~/.cabal/bin/:${PATH}"' >> $HOME/.bashrc
|
||||
|
||||
# nvm
|
||||
COPY . /home/nvm/.nvm/
|
||||
RUN sudo chown nvm:nvm -R $HOME/.nvm
|
||||
RUN echo 'export NVM_DIR="$HOME/.nvm"' >> $HOME/.bashrc
|
||||
RUN echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm' >> $HOME/.bashrc
|
||||
RUN echo '[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion' >> $HOME/.bashrc
|
||||
|
||||
# nodejs and tools
|
||||
RUN bash -c 'source $HOME/.nvm/nvm.sh && \
|
||||
nvm install node && \
|
||||
npm install -g doctoc urchin && \
|
||||
npm install --prefix "$HOME/.nvm/"'
|
||||
|
||||
# Set WORKDIR to nvm directory
|
||||
WORKDIR /home/nvm/.nvm
|
||||
|
||||
ENTRYPOINT /bin/bash
|
||||
|
||||
168
README.md
168
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 -->
|
||||
@@ -7,12 +7,14 @@
|
||||
- [Installation](#installation)
|
||||
- [Install script](#install-script)
|
||||
- [Verify installation](#verify-installation)
|
||||
- [Important Notes](#important-notes)
|
||||
- [Git install](#git-install)
|
||||
- [Manual Install](#manual-install)
|
||||
- [Manual upgrade](#manual-upgrade)
|
||||
- [Usage](#usage)
|
||||
- [Long-term support](#long-term-support)
|
||||
- [Migrating global packages while installing](#migrating-global-packages-while-installing)
|
||||
- [Default global packages from file while installing](#default-global-packages-from-file-while-installing)
|
||||
- [io.js](#iojs)
|
||||
- [System version of node](#system-version-of-node)
|
||||
- [Listing versions](#listing-versions)
|
||||
@@ -26,6 +28,7 @@
|
||||
- [Usage](#usage-1)
|
||||
- [Compatibility Issues](#compatibility-issues)
|
||||
- [Installing nvm on Alpine Linux](#installing-nvm-on-alpine-linux)
|
||||
- [Docker for development environment](#docker-for-development-environment)
|
||||
- [Problems](#problems)
|
||||
- [Mac OS "troubleshooting"](#mac-os-troubleshooting)
|
||||
|
||||
@@ -33,6 +36,61 @@
|
||||
|
||||
## Installation
|
||||
|
||||
### 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.33.7/install.sh | bash
|
||||
```
|
||||
|
||||
or Wget:
|
||||
|
||||
```sh
|
||||
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>
|
||||
|
||||
```sh
|
||||
export NVM_DIR="$HOME/.nvm"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
|
||||
```
|
||||
|
||||
You can customize the install source, directory, profile, and version using the `NVM_SOURCE`, `NVM_DIR`, `PROFILE`, and `NODE_VERSION` variables.
|
||||
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 Linux, after running the install script, if you get `nvm: command not found` or see no feedback from your terminal after you type:
|
||||
|
||||
```sh
|
||||
command -v nvm
|
||||
```
|
||||
simply close your current terminal, open a new terminal, and try verifying again.
|
||||
|
||||
**Note:** On OS X, if you get `nvm: command not found` after running the install script, one of the following might be the reason:-
|
||||
- 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
|
||||
- you might need to restart your terminal instance. Try opening a new tab/window in your terminal and retry.
|
||||
|
||||
If the above doesn't fix the problem, open your `.bash_profile` and add the following line of code:
|
||||
|
||||
`source ~/.bashrc`
|
||||
|
||||
- For more information about this issue and possible workarounds, please [refer here](https://github.com/creationix/nvm/issues/576)
|
||||
|
||||
### Verify installation
|
||||
|
||||
To verify that nvm has been installed, do:
|
||||
|
||||
```sh
|
||||
command -v nvm
|
||||
```
|
||||
|
||||
which should output 'nvm' if the installation was successful. Please note that `which nvm` will not work, since `nvm` is a sourced shell function, not an executable binary.
|
||||
|
||||
### Important Notes
|
||||
|
||||
If you're running a system without prepackaged binary available, which means you're going to install nodejs or io.js from its source code, you need to make sure your system has a C++ compiler. For OS X, Xcode will work, for Debian/Ubuntu based GNU/Linux, 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:
|
||||
@@ -63,66 +121,22 @@ Homebrew installation is not supported. If you have issues with homebrew-install
|
||||
|
||||
**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 widely 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.33.2/install.sh | bash
|
||||
```
|
||||
|
||||
or Wget:
|
||||
|
||||
```sh
|
||||
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/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>
|
||||
|
||||
```sh
|
||||
export NVM_DIR="$HOME/.nvm"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
|
||||
```
|
||||
|
||||
You can customize the install source, directory, profile, and version using the `NVM_SOURCE`, `NVM_DIR`, `PROFILE`, and `NODE_VERSION` variables.
|
||||
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.
|
||||
|
||||
If the above doesn't fix the problem, open your `.bash_profile` and add the following line of code:
|
||||
|
||||
`source ~/.bashrc`
|
||||
|
||||
- For more information about this issue and possible workarounds, please [refer here](https://github.com/creationix/nvm/issues/576)
|
||||
|
||||
|
||||
### Verify installation
|
||||
|
||||
To verify that nvm has been installed, do:
|
||||
|
||||
```sh
|
||||
command -v nvm
|
||||
```
|
||||
|
||||
which should output 'nvm' if the installation was successful. Please note that `which nvm` will not work, since `nvm` is a sourced shell function, not an executable binary.
|
||||
|
||||
### Git install
|
||||
|
||||
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.2`
|
||||
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)
|
||||
|
||||
```sh
|
||||
export NVM_DIR="$HOME/.nvm"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
|
||||
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
|
||||
```
|
||||
|
||||
### Manual Install
|
||||
@@ -228,6 +242,18 @@ nvm install 6 --reinstall-packages-from=5
|
||||
nvm install v4.2 --reinstall-packages-from=iojs
|
||||
```
|
||||
|
||||
### Default global packages from file while installing
|
||||
|
||||
If you have a list of default packages you want installed every time you install a new version we support that too. You can add anything npm would accept as a package argument on the command line.
|
||||
|
||||
```sh
|
||||
# $NVM_DIR/default-packages
|
||||
|
||||
rimraf
|
||||
object-inspect@1.0.2
|
||||
stevemao/left-pad
|
||||
```
|
||||
|
||||
### io.js
|
||||
If you want to install [io.js](https://github.com/iojs/io.js/):
|
||||
|
||||
@@ -299,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:
|
||||
|
||||
@@ -460,18 +486,48 @@ 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.2/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.
|
||||
|
||||
As a potential alternative, @mhart (a Node contributor) has some [Docker images for Alpine Linux with Node and optionally, npm, pre-installed](https://github.com/mhart/alpine-node).
|
||||
|
||||
## Docker for development environment
|
||||
|
||||
To make the development and testing work easier, we have a Dockerfile for development usage, which is based on Ubuntu 14.04 base image, prepared with essential and useful tools for `nvm` development, to build the docker image of the environment, run the docker command at the root of `nvm` repository:
|
||||
|
||||
```sh
|
||||
$ docker build -t nvm-dev .
|
||||
```
|
||||
|
||||
This will package your current nvm repository with our pre-defiend development environment into a docker image named `nvm-dev`, once it's built with success, validate your image via `docker images`:
|
||||
|
||||
```sh
|
||||
$ docker images
|
||||
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
nvm-dev latest 9ca4c57a97d8 7 days ago 1.22 GB
|
||||
```
|
||||
|
||||
If you got no error message, now you can easily involve in:
|
||||
|
||||
```sh
|
||||
$ 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 suitable for production usage.
|
||||
|
||||
For more information and documentation about docker, please refer to its official website:
|
||||
- https://www.docker.com/
|
||||
- https://docs.docker.com/
|
||||
|
||||
## 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.
|
||||
|
||||
@@ -483,7 +539,7 @@ As a potential alternative, @mhart (a Node contributor) has some [Docker images
|
||||
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"
|
||||
|
||||
@@ -498,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.2/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.2
|
||||
[4]: https://github.com/creationix/nvm/releases/tag/v0.33.7
|
||||
[Urchin]: https://github.com/scraperwiki/urchin
|
||||
[Fish]: http://fishshell.com
|
||||
|
||||
@@ -25,7 +25,8 @@ __nvm_commands ()
|
||||
help install uninstall use run exec
|
||||
alias unalias reinstall-packages
|
||||
current list ls list-remote ls-remote
|
||||
cache clear-cache deactivate unload
|
||||
install-latest-npm
|
||||
cache deactivate unload
|
||||
version version-remote which'
|
||||
|
||||
if [ ${#COMP_WORDS[@]} == 4 ]; then
|
||||
|
||||
48
install.sh
48
install.sh
@@ -11,7 +11,7 @@ nvm_install_dir() {
|
||||
}
|
||||
|
||||
nvm_latest_version() {
|
||||
echo "v0.33.2"
|
||||
echo "v0.33.7"
|
||||
}
|
||||
|
||||
nvm_profile_is_bash_or_zsh() {
|
||||
@@ -40,6 +40,8 @@ nvm_source() {
|
||||
NVM_SOURCE_URL="$NVM_SOURCE"
|
||||
if [ "_$NVM_METHOD" = "_script-nvm-exec" ]; then
|
||||
NVM_SOURCE_URL="https://raw.githubusercontent.com/creationix/nvm/$(nvm_latest_version)/nvm-exec"
|
||||
elif [ "_$NVM_METHOD" = "_script-nvm-bash-completion" ]; then
|
||||
NVM_SOURCE_URL="https://raw.githubusercontent.com/creationix/nvm/$(nvm_latest_version)/bash_completion"
|
||||
elif [ -z "$NVM_SOURCE_URL" ]; then
|
||||
if [ "_$NVM_METHOD" = "_script" ]; then
|
||||
NVM_SOURCE_URL="https://raw.githubusercontent.com/creationix/nvm/$(nvm_latest_version)/nvm.sh"
|
||||
@@ -84,7 +86,7 @@ install_nvm_from_git() {
|
||||
if [ -d "$INSTALL_DIR/.git" ]; then
|
||||
echo "=> nvm is already installed in $INSTALL_DIR, trying to update using git"
|
||||
command printf "\r=> "
|
||||
command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" fetch 2> /dev/null || {
|
||||
command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" fetch origin tag "$(nvm_latest_version)" --depth=1 2> /dev/null || {
|
||||
echo >&2 "Failed to update nvm, run 'git fetch' in $INSTALL_DIR yourself."
|
||||
exit 1
|
||||
}
|
||||
@@ -103,12 +105,12 @@ install_nvm_from_git() {
|
||||
echo >&2 'Failed to add remote "origin" (or set the URL). Please report this!'
|
||||
exit 2
|
||||
}
|
||||
command git --git-dir="${INSTALL_DIR}/.git" fetch origin --tags || {
|
||||
command git --git-dir="${INSTALL_DIR}/.git" fetch origin tag "$(nvm_latest_version)" --depth=1 || {
|
||||
echo >&2 'Failed to fetch origin with tags. Please report this!'
|
||||
exit 2
|
||||
}
|
||||
else
|
||||
command git clone "$(nvm_source)" "${INSTALL_DIR}" || {
|
||||
command git clone "$(nvm_source)" -b "$(nvm_latest_version)" --depth=1 "${INSTALL_DIR}" || {
|
||||
echo >&2 'Failed to clone nvm repo. Please report this!'
|
||||
exit 2
|
||||
}
|
||||
@@ -125,7 +127,10 @@ install_nvm_from_git() {
|
||||
fi
|
||||
|
||||
echo "=> Compressing and cleaning up git repository"
|
||||
if ! command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" gc --aggressive --prune=now ; then
|
||||
if ! command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" reflog expire --expire=now --all; then
|
||||
echo >&2 "Your version of git is out of date. Please update it!"
|
||||
fi
|
||||
if ! command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" gc --auto --aggressive --prune=now ; then
|
||||
echo >&2 "Your version of git is out of date. Please update it!"
|
||||
fi
|
||||
return
|
||||
@@ -135,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
|
||||
}
|
||||
|
||||
@@ -158,9 +163,11 @@ install_nvm_as_script() {
|
||||
local INSTALL_DIR
|
||||
INSTALL_DIR="$(nvm_install_dir)"
|
||||
local NVM_SOURCE_LOCAL
|
||||
NVM_SOURCE_LOCAL=$(nvm_source script)
|
||||
NVM_SOURCE_LOCAL="$(nvm_source script)"
|
||||
local NVM_EXEC_SOURCE
|
||||
NVM_EXEC_SOURCE=$(nvm_source script-nvm-exec)
|
||||
NVM_EXEC_SOURCE="$(nvm_source script-nvm-exec)"
|
||||
local NVM_BASH_COMPLETION_SOURCE
|
||||
NVM_BASH_COMPLETION_SOURCE="$(nvm_source script-nvm-bash-completion)"
|
||||
|
||||
# Downloading to $INSTALL_DIR
|
||||
mkdir -p "$INSTALL_DIR"
|
||||
@@ -177,6 +184,10 @@ install_nvm_as_script() {
|
||||
echo >&2 "Failed to download '$NVM_EXEC_SOURCE'"
|
||||
return 2
|
||||
} &
|
||||
nvm_download -s "$NVM_BASH_COMPLETION_SOURCE" -o "$INSTALL_DIR/bash_completion" || {
|
||||
echo >&2 "Failed to download '$NVM_BASH_COMPLETION_SOURCE'"
|
||||
return 2
|
||||
} &
|
||||
for job in $(jobs -p | sort)
|
||||
do
|
||||
wait "$job" || return $?
|
||||
@@ -319,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}"
|
||||
|
||||
296
nvm.sh
296
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}")"
|
||||
@@ -79,14 +73,18 @@ nvm_curl_libz_support() {
|
||||
curl -V 2>/dev/null | nvm_grep "^Features:" | nvm_grep -q "libz"
|
||||
}
|
||||
|
||||
nvm_curl_use_compression() {
|
||||
nvm_curl_libz_support && nvm_version_greater_than_or_equal_to "$(nvm_curl_version)" 7.21.0;
|
||||
}
|
||||
|
||||
nvm_get_latest() {
|
||||
local NVM_LATEST_URL
|
||||
local CURL_COMPRESSED_FLAG
|
||||
if nvm_has "curl"; then
|
||||
if nvm_curl_libz_support; then
|
||||
if nvm_curl_use_compression; then
|
||||
CURL_COMPRESSED_FLAG="--compressed"
|
||||
fi
|
||||
NVM_LATEST_URL="$(curl "${CURL_COMPRESSED_FLAG:-}" -q -w "%{url_effective}\n" -L -s -S http://latest.nvm.sh -o /dev/null)"
|
||||
NVM_LATEST_URL="$(curl ${CURL_COMPRESSED_FLAG:-} -q -w "%{url_effective}\n" -L -s -S http://latest.nvm.sh -o /dev/null)"
|
||||
elif nvm_has "wget"; then
|
||||
NVM_LATEST_URL="$(wget http://latest.nvm.sh --server-response -O /dev/null 2>&1 | command awk '/^ Location: /{DEST=$2} END{ print DEST }')"
|
||||
else
|
||||
@@ -103,14 +101,15 @@ nvm_get_latest() {
|
||||
nvm_download() {
|
||||
local CURL_COMPRESSED_FLAG
|
||||
if nvm_has "curl"; then
|
||||
if nvm_curl_libz_support; then
|
||||
if nvm_curl_use_compression; then
|
||||
CURL_COMPRESSED_FLAG="--compressed"
|
||||
fi
|
||||
curl "${CURL_COMPRESSED_FLAG:-}" -q "$@"
|
||||
curl --fail ${CURL_COMPRESSED_FLAG:-} -q "$@"
|
||||
elif nvm_has "wget"; then
|
||||
# Emulate curl with wget
|
||||
ARGS=$(nvm_echo "$@" | command sed -e 's/--progress-bar /--progress=bar /' \
|
||||
-e 's/--compressed //' \
|
||||
-e 's/--fail //' \
|
||||
-e 's/-L //' \
|
||||
-e 's/-I /--server-response /' \
|
||||
-e 's/-s /-q /' \
|
||||
@@ -139,6 +138,91 @@ nvm_print_npm_version() {
|
||||
fi
|
||||
}
|
||||
|
||||
nvm_install_latest_npm() {
|
||||
nvm_echo 'Attempting to upgrade to the latest working version of npm...'
|
||||
local NODE_VERSION
|
||||
NODE_VERSION="$(nvm_strip_iojs_prefix "$(nvm_ls_current)")"
|
||||
if [ "${NODE_VERSION}" = 'system' ]; then
|
||||
NODE_VERSION="$(node --version)"
|
||||
elif [ "${NODE_VERSION}" = 'none' ]; then
|
||||
nvm_echo "Detected node version ${NODE_VERSION}, npm version v${NPM_VERSION}"
|
||||
NODE_VERSION=''
|
||||
fi
|
||||
if [ -z "${NODE_VERSION}" ]; then
|
||||
nvm_err 'Unable to obtain node version.'
|
||||
return 1
|
||||
fi
|
||||
local NPM_VERSION
|
||||
NPM_VERSION="$(npm --version 2>/dev/null)"
|
||||
if [ -z "${NPM_VERSION}" ]; then
|
||||
nvm_err 'Unable to obtain npm version.'
|
||||
return 2
|
||||
fi
|
||||
|
||||
local NVM_NPM_CMD
|
||||
NVM_NPM_CMD='npm'
|
||||
if [ "${NVM_DEBUG-}" = 1 ]; then
|
||||
nvm_echo "Detected node version ${NODE_VERSION}, npm version v${NPM_VERSION}"
|
||||
NVM_NPM_CMD='echo npm'
|
||||
fi
|
||||
|
||||
local NVM_IS_0_6
|
||||
NVM_IS_0_6=0
|
||||
if nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 0.6.0 && nvm_version_greater 0.7.0 "${NODE_VERSION}"; then
|
||||
NVM_IS_0_6=1
|
||||
fi
|
||||
local NVM_IS_0_9
|
||||
NVM_IS_0_9=0
|
||||
if nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 0.9.0 && nvm_version_greater 0.10.0 "${NODE_VERSION}"; then
|
||||
NVM_IS_0_9=1
|
||||
fi
|
||||
|
||||
if [ $NVM_IS_0_6 -eq 1 ]; then
|
||||
nvm_echo '* `node` v0.6.x can only upgrade to `npm` v1.3.x'
|
||||
$NVM_NPM_CMD install -g npm@1.3
|
||||
elif [ $NVM_IS_0_9 -eq 0 ]; then
|
||||
# node 0.9 breaks here, for some reason
|
||||
if nvm_version_greater_than_or_equal_to "${NPM_VERSION}" 1.0.0 && nvm_version_greater 2.0.0 "${NPM_VERSION}"; then
|
||||
nvm_echo '* `npm` v1.x needs to first jump to `npm` v1.4.28 to be able to upgrade further'
|
||||
$NVM_NPM_CMD install -g npm@1.4.28
|
||||
elif nvm_version_greater_than_or_equal_to "${NPM_VERSION}" 2.0.0 && nvm_version_greater 3.0.0 "${NPM_VERSION}"; then
|
||||
nvm_echo '* `npm` v2.x needs to first jump to the latest v2 to be able to upgrade further'
|
||||
$NVM_NPM_CMD install -g npm@2
|
||||
fi
|
||||
fi
|
||||
|
||||
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 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
|
||||
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
|
||||
fi
|
||||
fi
|
||||
nvm_echo "* npm upgraded to: v$(npm --version 2>/dev/null)"
|
||||
}
|
||||
|
||||
# Make zsh glob matching behave same as bash
|
||||
# This fixes the "zsh: no matches found" errors
|
||||
if [ -z "${NVM_CD_FLAGS-}" ]; then
|
||||
@@ -183,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_}"
|
||||
}
|
||||
|
||||
|
||||
@@ -221,6 +305,10 @@ nvm_clang_version() {
|
||||
clang --version | command awk '{ if ($2 == "version") print $3; else if ($3 == "version") print $4 }' | command sed 's/-.*$//g'
|
||||
}
|
||||
|
||||
nvm_curl_version() {
|
||||
curl -V | command awk '{ if ($1 == "curl") print $2 }' | command sed 's/-.*$//g'
|
||||
}
|
||||
|
||||
nvm_version_greater() {
|
||||
command awk 'BEGIN {
|
||||
if (ARGV[1] == "" || ARGV[2] == "") exit(1)
|
||||
@@ -420,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
|
||||
@@ -516,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
|
||||
}
|
||||
|
||||
@@ -1887,7 +1986,7 @@ nvm_install_source() {
|
||||
make='gmake'
|
||||
;;
|
||||
esac
|
||||
if nvm_has "clang++" && nvm_has "clang" && nvm_version_greater_than_or_equal_to nvm_clang_version 3.5; then
|
||||
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++}"
|
||||
@@ -2163,6 +2262,14 @@ nvm() {
|
||||
return
|
||||
fi
|
||||
|
||||
local DEFAULT_IFS
|
||||
DEFAULT_IFS=" $(echo t | tr t \\t)
|
||||
"
|
||||
if [ "${IFS}" != "${DEFAULT_IFS}" ]; then
|
||||
IFS="${DEFAULT_IFS}" nvm "$@"
|
||||
return $?
|
||||
fi
|
||||
|
||||
local COMMAND
|
||||
COMMAND="${1-}"
|
||||
shift
|
||||
@@ -2189,11 +2296,13 @@ nvm() {
|
||||
nvm_echo
|
||||
nvm_echo 'Usage:'
|
||||
nvm_echo ' nvm --help Show this message'
|
||||
nvm_echo ' nvm --version Print out the latest released version of nvm'
|
||||
nvm_echo ' nvm --version Print out the installed version of nvm'
|
||||
nvm_echo ' nvm install [-s] <version> Download and install a <version>, [-s] from source. Uses .nvmrc if available'
|
||||
nvm_echo ' --reinstall-packages-from=<version> When installing, reinstall packages installed in <node|iojs|node version number>'
|
||||
nvm_echo ' --lts When installing, only select from LTS (long-term support) versions'
|
||||
nvm_echo ' --lts=<LTS name> When installing, only select from versions for a specific LTS line'
|
||||
nvm_echo ' --skip-default-packages When installing, skip the default-packages file if it exists'
|
||||
nvm_echo ' --latest-npm After installing, attempt to upgrade to the latest working npm on the given node version'
|
||||
nvm_echo ' nvm uninstall <version> Uninstall a version'
|
||||
nvm_echo ' nvm uninstall --lts Uninstall using automatic LTS (long-term support) alias `lts/*`, if available.'
|
||||
nvm_echo ' nvm uninstall --lts=<LTS name> Uninstall using automatic alias for provided LTS line, if available.'
|
||||
@@ -2222,6 +2331,7 @@ nvm() {
|
||||
nvm_echo ' nvm alias [<pattern>] Show all aliases beginning with <pattern>'
|
||||
nvm_echo ' nvm alias <name> <version> Set an alias named <name> pointing to <version>'
|
||||
nvm_echo ' nvm unalias <name> Deletes the alias named <name>'
|
||||
nvm_echo ' nvm install-latest-npm Attempt to upgrade to the latest working `npm` on the current node version'
|
||||
nvm_echo ' nvm reinstall-packages <version> Reinstall global `npm` packages contained in <version> to current version'
|
||||
nvm_echo ' nvm unload Unload `nvm` from shell'
|
||||
nvm_echo ' nvm which [<version>] Display path to installed node version. Uses .nvmrc if available'
|
||||
@@ -2229,11 +2339,12 @@ nvm() {
|
||||
nvm_echo ' nvm cache clear Empty cache directory for nvm'
|
||||
nvm_echo
|
||||
nvm_echo 'Example:'
|
||||
nvm_echo ' nvm install v0.10.32 Install a specific version number'
|
||||
nvm_echo ' nvm use 0.10 Use the latest available 0.10.x release'
|
||||
nvm_echo ' nvm run 0.10.32 app.js Run app.js using node v0.10.32'
|
||||
nvm_echo ' nvm exec 0.10.32 node app.js Run `node app.js` with the PATH pointing to node v0.10.32'
|
||||
nvm_echo ' nvm alias default 0.10.32 Set default node version on a shell'
|
||||
nvm_echo ' nvm install 8.0.0 Install a specific version number'
|
||||
nvm_echo ' nvm use 8.0 Use the latest available 8.0.x release'
|
||||
nvm_echo ' nvm run 6.10.3 app.js Run app.js using node 6.10.3'
|
||||
nvm_echo ' nvm exec 4.8.3 node app.js Run `node app.js` with the PATH pointing to node 4.8.3'
|
||||
nvm_echo ' nvm alias default 8.1.0 Set default node version on a shell'
|
||||
nvm_echo ' nvm alias default node Always default to the latest available node version on a shell'
|
||||
nvm_echo
|
||||
nvm_echo 'Note:'
|
||||
nvm_echo ' to remove, delete, or uninstall nvm - just remove the `$NVM_DIR` folder (usually `~/.nvm`)'
|
||||
@@ -2247,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
|
||||
;;
|
||||
@@ -2268,6 +2379,9 @@ nvm() {
|
||||
setopt shwordsplit
|
||||
fi
|
||||
nvm_err "nvm --version: v$(nvm --version)"
|
||||
if [ -n "${TERM_PROGRAM-}" ]; then
|
||||
nvm_err "\$TERM_PROGRAM: $TERM_PROGRAM"
|
||||
fi
|
||||
nvm_err "\$SHELL: $SHELL"
|
||||
nvm_err "\$HOME: $HOME"
|
||||
nvm_err "\$NVM_DIR: '$(nvm_sanitize_path "$NVM_DIR")'"
|
||||
@@ -2292,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)"
|
||||
|
||||
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 "git: not found"
|
||||
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
|
||||
@@ -2327,6 +2445,8 @@ nvm() {
|
||||
local nobinary
|
||||
nobinary=0
|
||||
local LTS
|
||||
local NVM_UPGRADE_NPM
|
||||
NVM_UPGRADE_NPM=0
|
||||
while [ $# -ne 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
@@ -2347,6 +2467,10 @@ nvm() {
|
||||
LTS="${1##--lts=}"
|
||||
shift
|
||||
;;
|
||||
--latest-npm)
|
||||
NVM_UPGRADE_NPM=1
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
break # stop parsing args
|
||||
;;
|
||||
@@ -2413,6 +2537,8 @@ nvm() {
|
||||
ADDITIONAL_PARAMETERS=''
|
||||
local PROVIDED_REINSTALL_PACKAGES_FROM
|
||||
local REINSTALL_PACKAGES_FROM
|
||||
local SKIP_DEFAULT_PACKAGES
|
||||
local DEFAULT_PACKAGES
|
||||
|
||||
while [ $# -ne 0 ]
|
||||
do
|
||||
@@ -2425,6 +2551,9 @@ nvm() {
|
||||
PROVIDED_REINSTALL_PACKAGES_FROM="$(nvm_echo "$1" | command cut -c 22-)"
|
||||
REINSTALL_PACKAGES_FROM="$(nvm_version "$PROVIDED_REINSTALL_PACKAGES_FROM")" ||:
|
||||
;;
|
||||
--skip-default-packages)
|
||||
SKIP_DEFAULT_PACKAGES=true
|
||||
;;
|
||||
*)
|
||||
ADDITIONAL_PARAMETERS="$ADDITIONAL_PARAMETERS $1"
|
||||
;;
|
||||
@@ -2432,6 +2561,30 @@ nvm() {
|
||||
shift
|
||||
done
|
||||
|
||||
if [ -z "${SKIP_DEFAULT_PACKAGES-}" ] && [ -f "${NVM_DIR}/default-packages" ]; then
|
||||
DEFAULT_PACKAGES=""
|
||||
|
||||
# Read lines from $NVM_DIR/default-packages
|
||||
local line
|
||||
while IFS=" " read -r line; do
|
||||
# Skip empty lines.
|
||||
[ -n "${line}" ] || continue
|
||||
|
||||
# Skip comment lines that begin with `#`.
|
||||
[ "$(echo "$line" | cut -c1)" != "#" ] || continue
|
||||
|
||||
# Fail on lines that have multiple space-separated words
|
||||
case ${line} in
|
||||
*\ * )
|
||||
nvm_err "Only one package per line is allowed in the ${NVM_DIR}/default-packages file. Please remove any lines with multiple space-seperated values."
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
DEFAULT_PACKAGES="${DEFAULT_PACKAGES}${line} "
|
||||
done < "${NVM_DIR}/default-packages"
|
||||
fi
|
||||
|
||||
if [ -n "${PROVIDED_REINSTALL_PACKAGES_FROM-}" ] && [ "$(nvm_ensure_version_prefix "${PROVIDED_REINSTALL_PACKAGES_FROM}")" = "${VERSION}" ]; then
|
||||
nvm_err "You can't reinstall global packages from the same version of node you're installing."
|
||||
return 4
|
||||
@@ -2449,9 +2602,17 @@ nvm() {
|
||||
|
||||
if nvm_is_version_installed "$VERSION"; then
|
||||
nvm_err "$VERSION is already installed."
|
||||
if nvm use "$VERSION" && [ ! -z "$REINSTALL_PACKAGES_FROM" ] && [ "_$REINSTALL_PACKAGES_FROM" != "_N/A" ]; then
|
||||
if nvm use "$VERSION"; then
|
||||
if [ "${NVM_UPGRADE_NPM}" = 1 ]; then
|
||||
nvm install-latest-npm
|
||||
fi
|
||||
if [ -z "${SKIP_DEFAULT_PACKAGES-}" ] && [ -n "${DEFAULT_PACKAGES-}" ]; then
|
||||
nvm_install_default_packages "$DEFAULT_PACKAGES"
|
||||
fi
|
||||
if [ -n "${REINSTALL_PACKAGES_FROM-}" ] && [ "_$REINSTALL_PACKAGES_FROM" != "_N/A" ]; then
|
||||
nvm reinstall-packages "$REINSTALL_PACKAGES_FROM"
|
||||
fi
|
||||
fi
|
||||
if [ -n "${LTS-}" ]; then
|
||||
nvm_ensure_default_set "lts/${LTS}"
|
||||
else
|
||||
@@ -2517,8 +2678,14 @@ nvm() {
|
||||
else
|
||||
nvm_ensure_default_set "$provided_version"
|
||||
fi
|
||||
if [ ! -z "$REINSTALL_PACKAGES_FROM" ] \
|
||||
&& [ "_$REINSTALL_PACKAGES_FROM" != "_N/A" ]; then
|
||||
if [ "${NVM_UPGRADE_NPM}" = 1 ]; then
|
||||
nvm install-latest-npm
|
||||
EXIT_CODE=$?
|
||||
fi
|
||||
if [ -z "${SKIP_DEFAULT_PACKAGES-}" ] && [ -n "${DEFAULT_PACKAGES-}" ]; then
|
||||
nvm_install_default_packages "$DEFAULT_PACKAGES"
|
||||
fi
|
||||
if [ -n "${REINSTALL_PACKAGES_FROM-}" ] && [ "_$REINSTALL_PACKAGES_FROM" != "_N/A" ]; then
|
||||
nvm reinstall-packages "$REINSTALL_PACKAGES_FROM"
|
||||
EXIT_CODE=$?
|
||||
fi
|
||||
@@ -2666,9 +2833,9 @@ nvm() {
|
||||
|
||||
if [ -n "${NVM_LTS-}" ]; then
|
||||
VERSION="$(nvm_match_version "lts/${NVM_LTS:-*}")"
|
||||
elif [ -z "$PROVIDED_VERSION" ]; then
|
||||
elif [ -z "${PROVIDED_VERSION-}" ]; then
|
||||
nvm_rc_version
|
||||
if [ -n "$NVM_RC_VERSION" ]; then
|
||||
if [ -n "${NVM_RC_VERSION-}" ]; then
|
||||
PROVIDED_VERSION="$NVM_RC_VERSION"
|
||||
VERSION="$(nvm_version "$PROVIDED_VERSION")"
|
||||
fi
|
||||
@@ -2717,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
|
||||
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
|
||||
@@ -2739,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)"
|
||||
@@ -3100,7 +3264,7 @@ nvm() {
|
||||
unset ALIAS
|
||||
fi
|
||||
|
||||
nvm_list_aliases "${ALIAS}"
|
||||
nvm_list_aliases "${ALIAS-}"
|
||||
fi
|
||||
;;
|
||||
"unalias" )
|
||||
@@ -3121,6 +3285,14 @@ nvm() {
|
||||
command rm -f "$NVM_ALIAS_DIR/${1}"
|
||||
nvm_echo "Deleted alias ${1} - restore it with \`nvm alias \"${1}\" \"$NVM_ALIAS_ORIGINAL\"\`"
|
||||
;;
|
||||
"install-latest-npm")
|
||||
if [ $# -ne 0 ]; then
|
||||
>&2 nvm --help
|
||||
return 127
|
||||
fi
|
||||
|
||||
nvm_install_latest_npm
|
||||
;;
|
||||
"reinstall-packages" | "copy-packages" )
|
||||
if [ $# -ne 1 ]; then
|
||||
>&2 nvm --help
|
||||
@@ -3157,6 +3329,7 @@ nvm() {
|
||||
nvm_echo "$INSTALLS" | command xargs npm install -g --quiet
|
||||
|
||||
nvm_echo "Linking global packages from $VERSION..."
|
||||
(
|
||||
set -f; IFS='
|
||||
' # necessary to turn off variable expansion except for newlines
|
||||
for LINK in $LINKS; do
|
||||
@@ -3165,11 +3338,11 @@ nvm() {
|
||||
(nvm_cd "$LINK" && npm link)
|
||||
fi
|
||||
done
|
||||
set +f; unset IFS # restore variable expansion in case $LINKS was empty
|
||||
)
|
||||
;;
|
||||
"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}"
|
||||
@@ -3210,7 +3383,7 @@ nvm() {
|
||||
NVM_VERSION_ONLY=true NVM_LTS="${NVM_LTS-}" nvm_remote_version "${PATTERN:-node}"
|
||||
;;
|
||||
"--version" )
|
||||
nvm_echo '0.33.2'
|
||||
nvm_echo '0.33.7'
|
||||
;;
|
||||
"unload" )
|
||||
nvm deactivate >/dev/null 2>&1
|
||||
@@ -3229,16 +3402,16 @@ 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 \
|
||||
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 \
|
||||
nvm_print_npm_version nvm_npm_global_modules \
|
||||
nvm_print_npm_version nvm_install_latest_npm nvm_npm_global_modules \
|
||||
nvm_has_system_node nvm_has_system_iojs \
|
||||
nvm_download nvm_get_latest nvm_has \
|
||||
nvm_download nvm_get_latest nvm_has nvm_install_default_packages nvm_curl_use_compression nvm_curl_version \
|
||||
nvm_supports_source_options nvm_auto nvm_supports_xz \
|
||||
nvm_echo nvm_err nvm_grep nvm_cd \
|
||||
nvm_die_on_prefix nvm_get_make_jobs nvm_get_minor_version \
|
||||
@@ -3250,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
|
||||
;;
|
||||
@@ -3261,6 +3434,15 @@ nvm() {
|
||||
esac
|
||||
}
|
||||
|
||||
nvm_install_default_packages() {
|
||||
nvm_echo "Installing default global packages from ${NVM_DIR}/default-packages..."
|
||||
|
||||
if ! nvm_echo "$1" | command xargs npm install -g --quiet; then
|
||||
nvm_err "Failed installing default packages. Please check if your default-packages file or a package in it has problems!"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
nvm_supports_source_options() {
|
||||
# shellcheck disable=SC1091
|
||||
[ "_$(echo '[ $# -gt 0 ] && echo $1' | . /dev/stdin yes 2> /dev/null)" = "_yes" ]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "nvm",
|
||||
"version": "0.33.2",
|
||||
"version": "0.33.7",
|
||||
"description": "Node Version Manager - Simple bash script to manage multiple active node.js versions",
|
||||
"directories": {
|
||||
"test": "test"
|
||||
|
||||
18
test/fast/Listing versions/Using a nonstandard IFS should not break
Executable file
18
test/fast/Listing versions/Using a nonstandard IFS should not break
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
mkdir "${NVM_DIR}/v0.0.1"
|
||||
mkdir "${NVM_DIR}/v0.0.3"
|
||||
mkdir "${NVM_DIR}/v0.0.9"
|
||||
mkdir "${NVM_DIR}/v0.3.1"
|
||||
mkdir "${NVM_DIR}/v0.3.3"
|
||||
mkdir "${NVM_DIR}/v0.3.9"
|
||||
mkdir -p "${NVM_DIR}/versions/node/v0.12.87"
|
||||
mkdir -p "${NVM_DIR}/versions/node/v0.12.9"
|
||||
mkdir -p "${NVM_DIR}/versions/io.js/v0.1.2"
|
||||
mkdir -p "${NVM_DIR}/versions/io.js/v0.10.2"
|
||||
|
||||
set -e
|
||||
|
||||
IFS='' nvm ls
|
||||
@@ -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'"
|
||||
|
||||
@@ -10,7 +10,9 @@ die () { echo "$@" ; cleanup ; exit 1; }
|
||||
|
||||
typeset -f | awk '/ \(\) $/ && !/^main / {print $1}' > "${BEFORE}"
|
||||
|
||||
set +e # TODO: fix
|
||||
\. ../../nvm.sh
|
||||
set -e
|
||||
|
||||
type nvm > /dev/null 2>&1 || die "nvm not loaded"
|
||||
|
||||
|
||||
@@ -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 "
|
||||
38
test/fast/Unit tests/nvm_curl_use_compression
Executable file
38
test/fast/Unit tests/nvm_curl_use_compression
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/bin/sh
|
||||
|
||||
cleanup () {
|
||||
unset -f die
|
||||
}
|
||||
|
||||
die () { echo -e "$@" ; cleanup ; exit 1; }
|
||||
|
||||
NVM_ENV=testing \. ../../../nvm.sh
|
||||
|
||||
curl() {
|
||||
if [ "$1" = "-V" ]; then
|
||||
echo "${VERSION_MESSAGE}"
|
||||
fi
|
||||
}
|
||||
|
||||
CURL_VERSION_ON_ARCHLINUX_WITH_LIBZ="curl 7.54.0 (x86_64-pc-linux-gnu) libcurl/7.54.0 OpenSSL/1.1.0f zlib/1.2.11 libpsl/0.17.0 (+libicu/59.1) libssh2/1.8.0 nghttp2/1.22.0
|
||||
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
|
||||
Features: AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL"
|
||||
|
||||
CURL_VERSION_ON_ARCHLINUX_WITHOUT_LIBZ="curl 7.54.0 (x86_64-pc-linux-gnu) libcurl/7.54.0 OpenSSL/1.1.0f zlib/1.2.11 libpsl/0.17.0 (+libicu/59.1) libssh2/1.8.0 nghttp2/1.22.0
|
||||
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
|
||||
Features: AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL"
|
||||
|
||||
CURL_VERSION_ON_CENTOS6_WITH_LIBZ="curl 7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.19.1 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2
|
||||
Protocols: tftp ftp telnet dict ldap ldaps http file https ftps scp sftp
|
||||
Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz"
|
||||
|
||||
VERSION_MESSAGE="${CURL_VERSION_ON_ARCHLINUX_WITH_LIBZ}"
|
||||
nvm_curl_use_compression || die "nvm_curl_use_compression should return 0"
|
||||
|
||||
VERSION_MESSAGE="${CURL_VERSION_ON_ARCHLINUX_WITHOUT_LIBZ}"
|
||||
! nvm_curl_use_compression || die "nvm_curl_use_compression should return 1 without libz support"
|
||||
|
||||
VERSION_MESSAGE="${CURL_VERSION_ON_CENTOS6_WITH_LIBZ}"
|
||||
! nvm_curl_use_compression || die "nvm_curl_use_compression should return 1 when curl < 7.21.0"
|
||||
|
||||
cleanup
|
||||
32
test/fast/Unit tests/nvm_curl_version
Executable file
32
test/fast/Unit tests/nvm_curl_version
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
cleanup () {
|
||||
unset -f die
|
||||
unset -f curl
|
||||
}
|
||||
|
||||
die () { echo -e "$@" ; cleanup ; exit 1; }
|
||||
|
||||
NVM_ENV=testing \. ../../../nvm.sh
|
||||
|
||||
curl() {
|
||||
if [ "$1" = "-V" ]; 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
|
||||
}
|
||||
|
||||
CURL_VERSION_MESSAGE="curl 7.54.0 (x86_64-pc-linux-gnu) libcurl/7.54.0 OpenSSL/1.1.0f zlib/1.2.11 libpsl/0.17.0 (+libicu/59.1) libssh2/1.8.0 nghttp2/1.22.0
|
||||
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
|
||||
Features: AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL"
|
||||
|
||||
VERSION_MESSAGE="${CURL_VERSION_MESSAGE}"
|
||||
assert_version_is "$(nvm_curl_version)" "7.54.0"
|
||||
|
||||
cleanup
|
||||
115
test/fast/Unit tests/nvm_default_packages
Executable file
115
test/fast/Unit tests/nvm_default_packages
Executable file
@@ -0,0 +1,115 @@
|
||||
#!/bin/sh
|
||||
|
||||
FILE="$NVM_DIR/default-packages"
|
||||
|
||||
die () { echo "$@" ; cleanup ; exit 1; }
|
||||
setup () {
|
||||
if [ -f $FILE ]; then
|
||||
ORIG_DEFAULT_PACKAGES=$(cat $FILE)
|
||||
mkdir ./tmp/ ||:
|
||||
mv $FILE ./tmp/default-packages ||:
|
||||
fi
|
||||
touch $FILE
|
||||
}
|
||||
cleanup () {
|
||||
rm -rf "$(nvm_version_path v6.10.1)" $FILE
|
||||
if [ "$ORIG_DEFAULT_PACKAGES" != "" ]; then
|
||||
rm -rf ./tmp/
|
||||
echo "$ORIG_DEFAULT_PACKAGES" > $FILE
|
||||
fi
|
||||
}
|
||||
|
||||
setup
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
cat > $FILE << EOF
|
||||
rimraf
|
||||
object-inspect@1.0.2
|
||||
|
||||
# commented-package
|
||||
|
||||
stevemao/left-pad
|
||||
EOF
|
||||
|
||||
nvm install v6.10.1 2>&1
|
||||
EXIT_CODE=$?
|
||||
[ "_$EXIT_CODE" = "_0" ] || die "expected 'nvm install v6.10.1' to exit with 0, got $EXIT_CODE"
|
||||
|
||||
nvm exec v6.10.1 npm ls -g --depth=0 | grep -q 'rimraf'
|
||||
if [ -z "$?" ]; then
|
||||
die "expected 'nvm exec v6.10.1 npm ls -g --depth=0 | grep -q 'rimraf'' to exit with 0, got $?"
|
||||
fi
|
||||
|
||||
cleanup
|
||||
|
||||
setup
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
cat > $FILE << EOF
|
||||
rimraf
|
||||
object-inspect@1.0.2
|
||||
|
||||
# commented-package
|
||||
|
||||
stevemao/left-pad
|
||||
EOF
|
||||
|
||||
nvm install v6.10.1 --skip-default-packages 2>&1
|
||||
EXIT_CODE=$?
|
||||
[ "_$EXIT_CODE" = "_0" ] || die "expected 'nvm install v6.10.1' to exit with 0, got $EXIT_CODE"
|
||||
|
||||
if nvm exec v6.10.1 npm ls -g --depth=0 | grep -q 'rimraf'; then
|
||||
die "expected 'nvm exec v6.10.1 npm ls -g --depth=0 | grep -q 'rimraf'' to be empty"
|
||||
fi
|
||||
|
||||
cleanup
|
||||
|
||||
setup
|
||||
|
||||
cat > $FILE << EOF
|
||||
not~a~package~name
|
||||
EOF
|
||||
|
||||
nvm install v6.10.1
|
||||
EXIT_CODE=$?
|
||||
[ "_$EXIT_CODE" = "_0" ] || die "expected 'nvm install v6.10.1' to exit with 0, got $EXIT_CODE"
|
||||
|
||||
if nvm exec v6.10.1 npm ls -g --depth=0 | grep -q 'not~a~package~name'; then
|
||||
die "expected 'nvm exec v6.10.1 npm ls -g --depth=0 | grep -q 'not~a~package~name'' to exit with 1, got $?"
|
||||
fi
|
||||
|
||||
cleanup
|
||||
|
||||
setup
|
||||
|
||||
cat > $FILE << EOF
|
||||
object-inspect @ 1.0.2
|
||||
EOF
|
||||
|
||||
nvm install v6.10.1 2>&1
|
||||
EXIT_CODE=$?
|
||||
[ "_$EXIT_CODE" = "_1" ] || die "expected 'nvm install v6.10.1' to exit with 1, got $EXIT_CODE"
|
||||
|
||||
if nvm exec v6.10.1 npm ls -g --depth=0 | grep -q 'object-inspect'; then
|
||||
die "expected 'nvm exec v6.10.1 npm ls -g --depth=0 | grep -q 'object-inspect'' to exit with 1, got $?"
|
||||
fi
|
||||
|
||||
cleanup
|
||||
|
||||
setup
|
||||
|
||||
rm -rf $FILE
|
||||
|
||||
nvm install v6.10.1 2>&1
|
||||
EXIT_CODE=$?
|
||||
[ "_$EXIT_CODE" = "_0" ] || die "expected 'nvm install v6.10.1' to exit with 0, got $EXIT_CODE"
|
||||
|
||||
if nvm exec v6.10.1 npm ls -g --depth=0 | grep -q 'object-inspect'; then
|
||||
die "expected 'nvm exec v6.10.1 npm ls -g --depth=0 | grep -q 'object-inspect'' to exit with 1, got $?"
|
||||
fi
|
||||
|
||||
touch $FILE
|
||||
|
||||
cleanup
|
||||
@@ -4,7 +4,9 @@ set -ex
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
set +e # TODO: fix
|
||||
\. ../../../nvm.sh
|
||||
set -e
|
||||
|
||||
ALG="$(nvm_get_checksum_alg)"
|
||||
|
||||
|
||||
@@ -7,7 +7,9 @@ die () { echo "$@" ; exit 1; }
|
||||
unset NVM_NODEJS_ORG_MIRROR
|
||||
unset NVM_IOJS_ORG_MIRROR
|
||||
|
||||
set +e # TODO: fix
|
||||
\. ../../../nvm.sh
|
||||
set -e
|
||||
|
||||
! nvm_get_mirror || die 'unknown release type did not error'
|
||||
! nvm_get_mirror node || die 'unknown release type did not error'
|
||||
@@ -28,4 +30,3 @@ unset NVM_NODEJS_ORG_MIRROR
|
||||
NVM_IOJS_ORG_MIRROR="test://domain"
|
||||
[ "$(nvm_get_mirror iojs std)" = "test://domain" ] || die "iojs-std mirror should respect NVM_IOJS_ORG_MIRROR"
|
||||
unset NVM_IOJS_ORG_MIRROR
|
||||
|
||||
|
||||
58
test/fast/Unit tests/nvm_install_latest_npm
Executable file
58
test/fast/Unit tests/nvm_install_latest_npm
Executable file
@@ -0,0 +1,58 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../common.sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
nvm deactivate >/dev/null 2>&1
|
||||
|
||||
CURRENT="$(nvm current)"
|
||||
[ "$CURRENT" = 'none' ] || [ "$CURRENT" = 'system' ] || die "nvm should be using none or system; got $CURRENT"
|
||||
|
||||
nvm_ls_current() {
|
||||
echo 'none'
|
||||
}
|
||||
node() {
|
||||
return 1
|
||||
}
|
||||
npm() {
|
||||
echo '1.2.3'
|
||||
}
|
||||
|
||||
OUTPUT="$(nvm_install_latest_npm 2>&1 >/dev/null)"
|
||||
EXIT_CODE="$(nvm_install_latest_npm >/dev/null 2>&1 ; echo $?)"
|
||||
|
||||
EXPECTED="Unable to obtain node version."
|
||||
[ "${OUTPUT}" = "${EXPECTED}" ] || die "When node is unavailable, expected >${EXPECTED}<; got >${OUTPUT}"
|
||||
|
||||
node() {
|
||||
echo 'v4.5.6'
|
||||
}
|
||||
nvm_ls_current() {
|
||||
node --version
|
||||
}
|
||||
npm() {
|
||||
return 1
|
||||
}
|
||||
OUTPUT="$(nvm_install_latest_npm 2>&1 >/dev/null)"
|
||||
EXIT_CODE="$(nvm_install_latest_npm >/dev/null 2>&1 ; echo $?)"
|
||||
|
||||
EXPECTED="Unable to obtain npm version."
|
||||
[ "${OUTPUT}" = "${EXPECTED}" ] || die "When node is available and npm is unavailable, expected >${EXPECTED}<; got >${OUTPUT}"
|
||||
|
||||
node() {
|
||||
echo 'v4.5.6'
|
||||
}
|
||||
nvm_ls_current() {
|
||||
echo 'system'
|
||||
}
|
||||
npm() {
|
||||
return 1
|
||||
}
|
||||
OUTPUT="$(nvm_install_latest_npm 2>&1 >/dev/null)"
|
||||
EXIT_CODE="$(nvm_install_latest_npm >/dev/null 2>&1 ; echo $?)"
|
||||
|
||||
EXPECTED="Unable to obtain npm version."
|
||||
[ "${OUTPUT}" = "${EXPECTED}" ] || die "When node is system and npm is unavailable, expected >${EXPECTED}<; got >${OUTPUT}"
|
||||
@@ -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; }
|
||||
|
||||
|
||||
41
test/installation_node/install latest npm
Executable file
41
test/installation_node/install latest npm
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
set +e # todo: fix
|
||||
\. ../../nvm.sh
|
||||
set -e
|
||||
|
||||
nvm deactivate >/dev/null 2>&1 || die 'unable to deactivate: 1'
|
||||
nvm install 4 >/dev/null 2>&1 || die 'install v4 failed'
|
||||
nvm install-latest-npm || die 'nvm install-latest-npm failed: 1'
|
||||
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.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: 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: 4'
|
||||
NPM_VERSION="$(npm --version)"
|
||||
[ "${NPM_VERSION}" = '4.5.0' ] || die "node 0.8.27 updates to ${NPM_VERSION}; expected v4.5.0"
|
||||
|
||||
## 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"
|
||||
12
test/installation_node/install with --latest-npm
Executable file
12
test/installation_node/install with --latest-npm
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
set +e # todo: fix
|
||||
\. ../../nvm.sh
|
||||
set -e
|
||||
|
||||
NVM_DEBUG=1 nvm install --latest-npm 4.2.2 \
|
||||
| grep 'Attempting to upgrade to the latest working version of npm...' || die 'did not call through to nvm_install_latest_npm'
|
||||
Reference in New Issue
Block a user