Compare commits
49 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
011810e721 | ||
|
|
d48abff659 | ||
|
|
82037b41b1 | ||
|
|
7b0a46eafb | ||
|
|
dcbecbf2c7 | ||
|
|
970cadf258 | ||
|
|
3cc9525dce | ||
|
|
6537c91eb5 | ||
|
|
07b20d5008 | ||
|
|
0b5bb5ccd8 | ||
|
|
45c1b84794 | ||
|
|
3664744e3b | ||
|
|
ee9e56582e | ||
|
|
e7a5b7992b | ||
|
|
ff77ac17af | ||
|
|
2410215b6a | ||
|
|
a1abfd1fe4 | ||
|
|
43402df896 | ||
|
|
1ede50cbae | ||
|
|
e0d87528f3 | ||
|
|
924a175bd8 | ||
|
|
9daf26f0a0 | ||
|
|
226487d358 | ||
|
|
216c24fba0 | ||
|
|
930507dbbc | ||
|
|
4c8ced736d | ||
|
|
1f7f0c2d81 | ||
|
|
41eb40821b | ||
|
|
c6740f5a6e | ||
|
|
04fdb2331b | ||
|
|
58d0933f72 | ||
|
|
2a5d2c06ff | ||
|
|
2a513a1bc0 | ||
|
|
48196d2436 | ||
|
|
7f9220dbd8 | ||
|
|
890fbb5581 | ||
|
|
e1bb44f712 | ||
|
|
db19450caa | ||
|
|
5c117e6ab3 | ||
|
|
02997b0753 | ||
|
|
cc0750eb5d | ||
|
|
7e715d5c73 | ||
|
|
66d2909650 | ||
|
|
a56c6f1485 | ||
|
|
703babe60a | ||
|
|
10f24d6d4b | ||
|
|
e367533eb8 | ||
|
|
6534568745 | ||
|
|
13f3cdcdf7 |
@@ -12,5 +12,11 @@ trim_trailing_whitespace = true
|
|||||||
[*.txt]
|
[*.txt]
|
||||||
indent_size = false
|
indent_size = false
|
||||||
|
|
||||||
|
[test/fast/Listing versions/Running "nvm ls" calls into nvm_alias]
|
||||||
|
indent_size = false
|
||||||
|
|
||||||
|
[test/fast/Listing versions/Running "nvm ls --no-alias" does not call into nvm_alias]
|
||||||
|
indent_size = false
|
||||||
|
|
||||||
[Makefile]
|
[Makefile]
|
||||||
indent_style = tab
|
indent_style = tab
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -15,7 +15,7 @@ npm-debug.log
|
|||||||
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
current
|
current
|
||||||
default-packages
|
/default-packages
|
||||||
|
|
||||||
# Only apps should have lockfiles
|
# Only apps should have lockfiles
|
||||||
npm-shrinkwrap.json
|
npm-shrinkwrap.json
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
language: generic
|
language: generic
|
||||||
dist: trusty
|
dist: xenial
|
||||||
sudo: required
|
sudo: required
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
@@ -36,8 +36,8 @@ before_cache:
|
|||||||
- if [ -n "${NODE-}" ]; then . nvm.sh && set -ex && nvm install --latest-npm "${NODE}" && npm --version; fi
|
- if [ -n "${NODE-}" ]; then . nvm.sh && set -ex && nvm install --latest-npm "${NODE}" && npm --version; fi
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
- CXX=g++-4.8
|
- CXX=g++
|
||||||
- CC=gcc-4.8
|
- CC=gcc
|
||||||
- PATH="$(echo $PATH | sed 's/::/:/')"
|
- PATH="$(echo $PATH | sed 's/::/:/')"
|
||||||
- PATH="/usr/lib/ccache/:$PATH"
|
- PATH="/usr/lib/ccache/:$PATH"
|
||||||
- NVM_DIR="${TRAVIS_BUILD_DIR}"
|
- NVM_DIR="${TRAVIS_BUILD_DIR}"
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
|||||||
ENV DEBIAN_FRONTEND noninteractive
|
ENV DEBIAN_FRONTEND noninteractive
|
||||||
|
|
||||||
# ShellCheck version
|
# ShellCheck version
|
||||||
ENV SHELLCHECK_VERSION=0.5.0
|
ENV SHELLCHECK_VERSION=0.6.0
|
||||||
|
|
||||||
# Pick a Ubuntu apt mirror site for better speed
|
# Pick a Ubuntu apt mirror site for better speed
|
||||||
# ref: https://launchpad.net/ubuntu/+archivemirrors
|
# ref: https://launchpad.net/ubuntu/+archivemirrors
|
||||||
@@ -42,6 +42,7 @@ RUN apt update && \
|
|||||||
bsdutils \
|
bsdutils \
|
||||||
file \
|
file \
|
||||||
openssl \
|
openssl \
|
||||||
|
libssl-dev \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
ssh \
|
ssh \
|
||||||
wget \
|
wget \
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ The MIT License (MIT)
|
|||||||
|
|
||||||
Copyright (c) 2010 Tim Caswell
|
Copyright (c) 2010 Tim Caswell
|
||||||
|
|
||||||
|
Copyright (c) 2014 Jordan Harband
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
this software and associated documentation files (the "Software"), to deal in
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
the Software without restriction, including without limitation the rights to
|
the Software without restriction, including without limitation the rights to
|
||||||
|
|||||||
125
README.md
125
README.md
@@ -1,11 +1,11 @@
|
|||||||
# 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 -->
|
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
||||||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
|
|
||||||
- [Installation](#installation)
|
- [Installation and Update](#installation-and-update)
|
||||||
- [Install script](#install-script)
|
- [Install & Update script](#install--update-script)
|
||||||
- [Ansible](#ansible)
|
- [Ansible](#ansible)
|
||||||
- [Verify installation](#verify-installation)
|
- [Verify installation](#verify-installation)
|
||||||
- [Important Notes](#important-notes)
|
- [Important Notes](#important-notes)
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
- [io.js](#iojs)
|
- [io.js](#iojs)
|
||||||
- [System version of node](#system-version-of-node)
|
- [System version of node](#system-version-of-node)
|
||||||
- [Listing versions](#listing-versions)
|
- [Listing versions](#listing-versions)
|
||||||
|
- [Suppressing colorized output](#suppressing-colorized-output)
|
||||||
- [.nvmrc](#nvmrc)
|
- [.nvmrc](#nvmrc)
|
||||||
- [Deeper Shell Integration](#deeper-shell-integration)
|
- [Deeper Shell Integration](#deeper-shell-integration)
|
||||||
- [bash](#bash)
|
- [bash](#bash)
|
||||||
@@ -39,20 +40,20 @@
|
|||||||
|
|
||||||
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
||||||
|
|
||||||
## Installation
|
## Installation and Update
|
||||||
|
|
||||||
### Install script
|
### Install & Update script
|
||||||
|
|
||||||
To install or update nvm, you can use the [install script][2] using cURL:
|
To **install** or **update** nvm, you can use the [install script][2] using cURL:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
|
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | bash
|
||||||
```
|
```
|
||||||
|
|
||||||
or Wget:
|
or Wget:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
|
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/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>
|
<sub>The script clones the nvm repository to `~/.nvm` and adds the source line to your profile (`~/.bash_profile`, `~/.zshrc`, `~/.profile`, or `~/.bashrc`).</sub>
|
||||||
@@ -60,7 +61,7 @@ wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh |
|
|||||||
<sub>**Note:** If the environment variable `$XDG_CONFIG_HOME` is present, it will place the `nvm` files there.</sub>
|
<sub>**Note:** If the environment variable `$XDG_CONFIG_HOME` is present, it will place the `nvm` files there.</sub>
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
export NVM_DIR="${XDG_CONFIG_HOME/:-$HOME/.}nvm"
|
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_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
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -79,18 +80,18 @@ command -v nvm
|
|||||||
|
|
||||||
simply close your current terminal, open a new terminal, and try verifying again.
|
simply close your current terminal, open a new terminal, and try verifying again.
|
||||||
|
|
||||||
**Note:** Since OS X 10.9, `/usr/bin/git` has been preset by Xcode command line tools, which means we can't properly detect if Git is installed or not. You need to manually install the Xcode command line tools before running the install script, otherwise, it'll fail. (see [#1782](https://github.com/creationix/nvm/issues/1782))
|
**Note:** Since OS X 10.9, `/usr/bin/git` has been preset by Xcode command line tools, which means we can't properly detect if Git is installed or not. You need to manually install the Xcode command line tools before running the install script, otherwise, it'll fail. (see [#1782](https://github.com/nvm-sh/nvm/issues/1782))
|
||||||
|
|
||||||
**Note:** On OS X, if you get `nvm: command not found` after running the install script, one of the following might be the reason:-
|
**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
|
- your system may not have a `.bash_profile` file where the command is set up. 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.
|
- 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:
|
If the above doesn't fix the problem, open your `.bash_profile` and add the following line of code:
|
||||||
|
|
||||||
`source ~/.bashrc`
|
`source ~/.bashrc`
|
||||||
|
|
||||||
- For more information about this issue and possible workarounds, please [refer here](https://github.com/creationix/nvm/issues/576)
|
- For more information about this issue and possible workarounds, please [refer here](https://github.com/nvm-sh/nvm/issues/576)
|
||||||
|
|
||||||
#### Ansible
|
#### Ansible
|
||||||
You can use a task:
|
You can use a task:
|
||||||
@@ -98,7 +99,7 @@ If the above doesn't fix the problem, open your `.bash_profile` and add the foll
|
|||||||
```
|
```
|
||||||
- name: nvm
|
- name: nvm
|
||||||
shell: >
|
shell: >
|
||||||
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
|
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | bash
|
||||||
args:
|
args:
|
||||||
creates: "{{ ansible_env.HOME }}/.nvm/nvm.sh"
|
creates: "{{ ansible_env.HOME }}/.nvm/nvm.sh"
|
||||||
```
|
```
|
||||||
@@ -111,18 +112,18 @@ To verify that nvm has been installed, do:
|
|||||||
command -v nvm
|
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.
|
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
|
### 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.
|
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:
|
**Note:** `nvm` does not support Windows (see [#284](https://github.com/nvm-sh/nvm/issues/284)), but may work in WSL (Windows Subsystem for Linux) depending on the version of WSL. For Windows, two alternatives exist, which are neither supported nor developed by us:
|
||||||
|
|
||||||
- [nvm-windows](https://github.com/coreybutler/nvm-windows)
|
- [nvm-windows](https://github.com/coreybutler/nvm-windows)
|
||||||
- [nodist](https://github.com/marcelklehr/nodist)
|
- [nodist](https://github.com/marcelklehr/nodist)
|
||||||
|
|
||||||
**Note:** `nvm` does not support [Fish] either (see [#303](https://github.com/creationix/nvm/issues/303)). Alternatives exist, which are neither supported nor developed by us:
|
**Note:** `nvm` does not support [Fish] either (see [#303](https://github.com/nvm-sh/nvm/issues/303)). Alternatives exist, which are neither supported nor developed by us:
|
||||||
|
|
||||||
- [bass](https://github.com/edc/bass) allows you to use utilities written for Bash in fish shell
|
- [bass](https://github.com/edc/bass) allows you to use utilities written for Bash in fish shell
|
||||||
- [fast-nvm-fish](https://github.com/brigand/fast-nvm-fish) only works with version numbers (not aliases) but doesn't significantly slow your shell startup
|
- [fast-nvm-fish](https://github.com/brigand/fast-nvm-fish) only works with version numbers (not aliases) but doesn't significantly slow your shell startup
|
||||||
@@ -132,7 +133,7 @@ If you're running a system without prepackaged binary available, which means you
|
|||||||
|
|
||||||
**Note:** We still have some problems with FreeBSD, because there is no official pre-built binary for FreeBSD, and building from source may need [patches](https://www.freshports.org/www/node/files/patch-deps_v8_src_base_platform_platform-posix.cc); see the issue ticket:
|
**Note:** We still have some problems with FreeBSD, because there is no official pre-built binary for FreeBSD, and building from source may need [patches](https://www.freshports.org/www/node/files/patch-deps_v8_src_base_platform_platform-posix.cc); see the issue ticket:
|
||||||
|
|
||||||
- [[#900] [Bug] nodejs on FreeBSD may need to be patched](https://github.com/creationix/nvm/issues/900)
|
- [[#900] [Bug] nodejs on FreeBSD may need to be patched](https://github.com/nvm-sh/nvm/issues/900)
|
||||||
- [nodejs/node#3716](https://github.com/nodejs/node/issues/3716)
|
- [nodejs/node#3716](https://github.com/nodejs/node/issues/3716)
|
||||||
|
|
||||||
**Note:** On OS X, if you do not have Xcode installed and you do not wish to download the ~4.3GB file, you can install the `Command Line Tools`. You can check out this blog post on how to just that:
|
**Note:** On OS X, if you do not have Xcode installed and you do not wish to download the ~4.3GB file, you can install the `Command Line Tools`. You can check out this blog post on how to just that:
|
||||||
@@ -141,24 +142,24 @@ If you're running a system without prepackaged binary available, which means you
|
|||||||
|
|
||||||
**Note:** On OS X, if you have/had a "system" node installed and want to install modules globally, keep in mind that:
|
**Note:** On OS X, if you have/had a "system" node installed and want to install modules globally, keep in mind that:
|
||||||
|
|
||||||
- When using nvm you do not need `sudo` to globally install a module with `npm -g`, so instead of doing `sudo npm install -g grunt`, do instead `npm install -g grunt`
|
- When using `nvm` you do not need `sudo` to globally install a module with `npm -g`, so instead of doing `sudo npm install -g grunt`, do instead `npm install -g grunt`
|
||||||
- If you have an `~/.npmrc` file, make sure it does not contain any `prefix` settings (which is not compatible with nvm)
|
- If you have an `~/.npmrc` file, make sure it does not contain any `prefix` settings (which is not compatible with `nvm`)
|
||||||
- You can (but should not?) keep your previous "system" node install, but nvm will only be available to your user account (the one used to install nvm). This might cause version mismatches, as other users will be using `/usr/local/lib/node_modules/*` VS your user account using `~/.nvm/versions/node/vX.X.X/lib/node_modules/*`
|
- You can (but should not?) keep your previous "system" node install, but `nvm` will only be available to your user account (the one used to install nvm). This might cause version mismatches, as other users will be using `/usr/local/lib/node_modules/*` VS your user account using `~/.nvm/versions/node/vX.X.X/lib/node_modules/*`
|
||||||
|
|
||||||
Homebrew installation is not supported. If you have issues with homebrew-installed `nvm`, please `brew uninstall` it, and install it using the instructions below, before filing an issue.
|
Homebrew installation is not supported. If you have issues with homebrew-installed `nvm`, please `brew uninstall` it, and install it using the instructions below, before filing an issue.
|
||||||
|
|
||||||
**Note:** If you're using `zsh` you can easily install `nvm` as a zsh plugin. Install [`zsh-nvm`](https://github.com/lukechilds/zsh-nvm) and run `nvm upgrade` to upgrade.
|
**Note:** If you're using `zsh` you can easily install `nvm` as a zsh plugin. Install [`zsh-nvm`](https://github.com/lukechilds/zsh-nvm) and run `nvm upgrade` to upgrade.
|
||||||
|
|
||||||
**Note:** Git versions before v1.7 may face a problem of cloning nvm source from GitHub via https protocol, and there is also different behavior of git before v1.6, and git prior to [v1.17.10](https://github.com/git/git/commit/5a7d5b683f869d3e3884a89775241afa515da9e7) can not clone tags, so the minimum required git version is v1.7.10. If you are interested in the problem we mentioned here, please refer to GitHub's [HTTPS cloning errors](https://help.github.com/articles/https-cloning-errors/) article.
|
**Note:** Git versions before v1.7 may face a problem of cloning `nvm` source from GitHub via https protocol, and there is also different behavior of git before v1.6, and git prior to [v1.17.10](https://github.com/git/git/commit/5a7d5b683f869d3e3884a89775241afa515da9e7) can not clone tags, so the minimum required git version is v1.7.10. 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.
|
||||||
|
|
||||||
### Git install
|
### Git install
|
||||||
|
|
||||||
If you have `git` installed (requires git v1.7.10+):
|
If you have `git` installed (requires git v1.7.10+):
|
||||||
|
|
||||||
1. clone this repo in the root of your user profile
|
1. clone this repo in the root of your user profile
|
||||||
- `cd ~/` from anywhere then `git clone https://github.com/creationix/nvm.git .nvm`
|
- `cd ~/` from anywhere then `git clone https://github.com/nvm-sh/nvm.git .nvm`
|
||||||
1. `cd ~/.nvm` and check out the latest version with `git checkout v0.34.0`
|
1. `cd ~/.nvm` and check out the latest version with `git checkout v0.35.0`
|
||||||
1. activate nvm by sourcing it from your shell: `. nvm.sh`
|
1. 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:
|
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)
|
(you may have to add to more than one of the above files)
|
||||||
@@ -171,11 +172,11 @@ export NVM_DIR="$HOME/.nvm"
|
|||||||
|
|
||||||
### Manual Install
|
### Manual Install
|
||||||
|
|
||||||
For a fully manual install, execute the following lines to first clone the nvm repository into `$HOME/.nvm`, and then load nvm:
|
For a fully manual install, execute the following lines to first clone the `nvm` repository into `$HOME/.nvm`, and then load `nvm`:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
export NVM_DIR="$HOME/.nvm" && (
|
export NVM_DIR="$HOME/.nvm" && (
|
||||||
git clone https://github.com/creationix/nvm.git "$NVM_DIR"
|
git clone https://github.com/nvm-sh/nvm.git "$NVM_DIR"
|
||||||
cd "$NVM_DIR"
|
cd "$NVM_DIR"
|
||||||
git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)`
|
git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)`
|
||||||
) && \. "$NVM_DIR/nvm.sh"
|
) && \. "$NVM_DIR/nvm.sh"
|
||||||
@@ -220,7 +221,9 @@ To install a specific version of node:
|
|||||||
nvm install 6.14.4 # or 10.10.0, 8.9.1, etc
|
nvm install 6.14.4 # or 10.10.0, 8.9.1, etc
|
||||||
```
|
```
|
||||||
|
|
||||||
You can list available versions using ls-remote:
|
The first version installed becomes the default. New shells will start with the default version of node (e.g., `nvm alias default`).
|
||||||
|
|
||||||
|
You can list available versions using `ls-remote`:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
nvm ls-remote
|
nvm ls-remote
|
||||||
@@ -259,7 +262,7 @@ In place of a version pointer like "0.10" or "5.0" or "4.2.1", you can use the f
|
|||||||
|
|
||||||
### Long-term support
|
### Long-term support
|
||||||
|
|
||||||
Node has a [schedule](https://github.com/nodejs/LTS#lts_schedule) for long-term support (LTS) You can reference LTS versions in aliases and `.nvmrc` files with the notation `lts/*` for the latest LTS, and `lts/argon` for LTS releases from the "argon" line, for example. In addition, the following commands support LTS arguments:
|
Node has a [schedule](https://github.com/nodejs/Release#release-schedule) for long-term support (LTS) You can reference LTS versions in aliases and `.nvmrc` files with the notation `lts/*` for the latest LTS, and `lts/argon` for LTS releases from the "argon" line, for example. In addition, the following commands support LTS arguments:
|
||||||
|
|
||||||
- `nvm install --lts` / `nvm install --lts=argon` / `nvm install 'lts/*'` / `nvm install lts/argon`
|
- `nvm install --lts` / `nvm install --lts=argon` / `nvm install 'lts/*'` / `nvm install lts/argon`
|
||||||
- `nvm uninstall --lts` / `nvm uninstall --lts=argon` / `nvm uninstall 'lts/*'` / `nvm uninstall lts/argon`
|
- `nvm uninstall --lts` / `nvm uninstall --lts=argon` / `nvm uninstall 'lts/*'` / `nvm uninstall lts/argon`
|
||||||
@@ -288,9 +291,25 @@ nvm install 6 --reinstall-packages-from=5
|
|||||||
nvm install v4.2 --reinstall-packages-from=iojs
|
nvm install v4.2 --reinstall-packages-from=iojs
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Note that reinstalling packages _explicitly does not update the npm version_ — this is to ensure that npm isn't accidentally upgraded to a broken version for the new node version.
|
||||||
|
|
||||||
|
To update npm at the same time add the `--latest-npm` flag, like this:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
nvm install lts/* --reinstall-packages-from=default --latest-npm
|
||||||
|
```
|
||||||
|
|
||||||
|
or, you can at any time run the following command to get the latest supported npm version on the current node version:
|
||||||
|
```sh
|
||||||
|
nvm install-latest-npm
|
||||||
|
```
|
||||||
|
|
||||||
|
If you've already gotten an error to the effect of "npm does not support Node.js", you'll need to (1) revert to a previous node version (`nvm ls` & `nvm use <your latest _working_ version from the ls>`, (2) delete the newly created node version (`nvm uninstall <your _broken_ version of node from the ls>`), then (3) rerun your `nvm install` with the `--latest-npm` flag.
|
||||||
|
|
||||||
|
|
||||||
### Default global packages from file while installing
|
### 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.
|
If you have a list of default packages you want installed every time you install a new version, we support that too -- just add the package names, one per line, to the file `$NVM_DIR/default-packages`. You can add anything npm would accept as a package argument on the command line.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# $NVM_DIR/default-packages
|
# $NVM_DIR/default-packages
|
||||||
@@ -314,7 +333,7 @@ If you want to install a new version of io.js and migrate npm packages from a pr
|
|||||||
nvm install iojs --reinstall-packages-from=iojs
|
nvm install iojs --reinstall-packages-from=iojs
|
||||||
```
|
```
|
||||||
|
|
||||||
The same guidelines mentioned for migrating npm packages in Node.js are applicable to io.js.
|
The same guidelines mentioned for migrating npm packages in node are applicable to io.js.
|
||||||
|
|
||||||
### System version of node
|
### System version of node
|
||||||
|
|
||||||
@@ -339,6 +358,15 @@ If you want to see what versions are available to install:
|
|||||||
nvm ls-remote
|
nvm ls-remote
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Suppressing colorized output
|
||||||
|
|
||||||
|
`nvm ls`, `nvm ls-remote` and `nvm alias` usually produce colorized output. You can disable colors with the `--no-colors` option (or by setting the environment variable `TERM=dumb`):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
nvm ls --no-colors
|
||||||
|
TERM=dumb nvm ls
|
||||||
|
```
|
||||||
|
|
||||||
To restore your PATH, you can deactivate it:
|
To restore your PATH, you can deactivate it:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
@@ -445,17 +473,18 @@ cdnvm(){
|
|||||||
declare nvm_version
|
declare nvm_version
|
||||||
nvm_version=$(<"$nvm_path"/.nvmrc)
|
nvm_version=$(<"$nvm_path"/.nvmrc)
|
||||||
|
|
||||||
# Add the `v` suffix if it does not exists in the .nvmrc file
|
declare locally_resolved_nvm_version
|
||||||
if [[ $nvm_version != v* ]]; then
|
# `nvm ls` will check all locally-available versions
|
||||||
nvm_version="v""$nvm_version"
|
# If there are multiple matching versions, take the latest one
|
||||||
fi
|
# Remove the `->` and `*` characters and spaces
|
||||||
|
# `locally_resolved_nvm_version` will be `N/A` if no local versions are found
|
||||||
|
locally_resolved_nvm_version=$(nvm ls --no-colors "$nvm_version" | tail -1 | tr -d '\->*' | tr -d '[:space:]')
|
||||||
|
|
||||||
# If it is not already installed, install it
|
# If it is not already installed, install it
|
||||||
if [[ $(nvm ls "$nvm_version" | tr -d '[:space:]') == "N/A" ]]; then
|
# `nvm install` will implicitly use the newly-installed version
|
||||||
|
if [[ "$locally_resolved_nvm_version" == "N/A" ]]; then
|
||||||
nvm install "$nvm_version";
|
nvm install "$nvm_version";
|
||||||
fi
|
elif [[ $(nvm current) != "$locally_resolved_nvm_version" ]]; then
|
||||||
|
|
||||||
if [[ $(nvm current) != "$nvm_version" ]]; then
|
|
||||||
nvm use "$nvm_version";
|
nvm use "$nvm_version";
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -616,7 +645,7 @@ If installing nvm on Alpine Linux *is* still what you want or need to do, you sh
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
apk add -U curl bash ca-certificates openssl ncurses coreutils python2 make gcc g++ libgcc linux-headers grep util-linux binutils findutils
|
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.34.0/install.sh | bash
|
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/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.
|
The Node project has some desire but no concrete plans (due to the overheads of building, testing and support) to offer Alpine-compatible binaries.
|
||||||
@@ -627,13 +656,13 @@ As a potential alternative, @mhart (a Node contributor) has some [Docker images
|
|||||||
|
|
||||||
### Manual Uninstall
|
### Manual Uninstall
|
||||||
|
|
||||||
To remove nvm manually, execute the following:
|
To remove `nvm` manually, execute the following:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ rm -rf "$NVM_DIR"
|
$ rm -rf "$NVM_DIR"
|
||||||
```
|
```
|
||||||
|
|
||||||
Edit ~/.bashrc (or other shell resource config) and remove the lines below:
|
Edit `~/.bashrc` (or other shell resource config) and remove the lines below:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
export NVM_DIR="$HOME/.nvm"
|
export NVM_DIR="$HOME/.nvm"
|
||||||
@@ -675,11 +704,11 @@ For more information and documentation about docker, please refer to its officia
|
|||||||
|
|
||||||
## Problems
|
## 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 run `nvm cache clear` to delete cached node downloads, or you might get an error like the following:
|
||||||
|
|
||||||
curl: (33) HTTP server doesn't seem to support byte ranges. Cannot resume.
|
curl: (33) HTTP server doesn't seem to support byte ranges. Cannot resume.
|
||||||
|
|
||||||
- Where's my `sudo node`? Check out [#43](https://github.com/creationix/nvm/issues/43)
|
- Where's my `sudo node`? Check out [#43](https://github.com/nvm-sh/nvm/issues/43)
|
||||||
|
|
||||||
- After the v0.8.6 release of node, nvm tries to install from binary packages. But in some systems, the official binary packages don't work due to incompatibility of shared libs. In such cases, use `-s` option to force install from source:
|
- After the v0.8.6 release of node, nvm tries to install from binary packages. But in some systems, the official binary packages don't work due to incompatibility of shared libs. In such cases, use `-s` option to force install from source:
|
||||||
|
|
||||||
@@ -687,7 +716,7 @@ For more information and documentation about docker, please refer to its officia
|
|||||||
nvm install -s 0.8.6
|
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/nvm-sh/nvm/issues/658))
|
||||||
|
|
||||||
## Mac OS "troubleshooting"
|
## Mac OS "troubleshooting"
|
||||||
|
|
||||||
@@ -701,9 +730,9 @@ sudo chmod ugo-x /usr/libexec/path_helper
|
|||||||
|
|
||||||
More on this issue in [dotphiles/dotzsh](https://github.com/dotphiles/dotzsh#mac-os-x).
|
More on this issue in [dotphiles/dotzsh](https://github.com/dotphiles/dotzsh#mac-os-x).
|
||||||
|
|
||||||
[1]: https://github.com/creationix/nvm.git
|
[1]: https://github.com/nvm-sh/nvm.git
|
||||||
[2]: https://github.com/creationix/nvm/blob/v0.34.0/install.sh
|
[2]: https://github.com/nvm-sh/nvm/blob/v0.35.0/install.sh
|
||||||
[3]: https://travis-ci.org/creationix/nvm
|
[3]: https://travis-ci.org/nvm-sh/nvm
|
||||||
[4]: https://github.com/creationix/nvm/releases/tag/v0.34.0
|
[4]: https://github.com/nvm-sh/nvm/releases/tag/v0.35.0
|
||||||
[Urchin]: https://github.com/scraperwiki/urchin
|
[Urchin]: https://github.com/scraperwiki/urchin
|
||||||
[Fish]: http://fishshell.com
|
[Fish]: http://fishshell.com
|
||||||
|
|||||||
10
ROADMAP.md
10
ROADMAP.md
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This is a list of the primary features planned for `nvm`:
|
This is a list of the primary features planned for `nvm`:
|
||||||
|
|
||||||
- [x] Rewriting installation code paths to support installing `io.js` and `node` `v4+` [from source](https://github.com/creationix/nvm/issues/1188).
|
- [x] Rewriting installation code paths to support installing `io.js` and `node` `v4+` [from source](https://github.com/nvm-sh/nvm/issues/1188).
|
||||||
- This will include [reusing previously downloaded tarballs](https://github.com/creationix/nvm/issues/1193) that match checksums, which is a nice performance and bandwidth bonus.
|
- This will include [reusing previously downloaded tarballs](https://github.com/nvm-sh/nvm/issues/1193) that match checksums, which is a nice performance and bandwidth bonus.
|
||||||
- [ ] Adding opt-in environment variable support to list, download, and install `node` [release candidates](https://github.com/creationix/nvm/issues/779), and [nightly builds](https://github.com/creationix/nvm/issues/1053).
|
- [ ] Adding opt-in environment variable support to list, download, and install `node` [release candidates](https://github.com/nvm-sh/nvm/issues/779), and [nightly builds](https://github.com/nvm-sh/nvm/issues/1053).
|
||||||
- [ ] [`nvm update`](https://github.com/creationix/nvm/issues/400): the ability to autoupdate `nvm` itself
|
- [ ] [`nvm update`](https://github.com/nvm-sh/nvm/issues/400): the ability to autoupdate `nvm` itself
|
||||||
- [ ] [v1.0.0](https://github.com/creationix/nvm/milestone/1), including updating the [nvm on npm](https://github.com/creationix/nvm/issues/304) to auto-install nvm properly
|
- [ ] [v1.0.0](https://github.com/nvm-sh/nvm/milestone/1), including updating the [nvm on npm](https://github.com/nvm-sh/nvm/issues/304) to auto-install nvm properly
|
||||||
|
|||||||
33
install.sh
33
install.sh
@@ -6,18 +6,20 @@ nvm_has() {
|
|||||||
type "$1" > /dev/null 2>&1
|
type "$1" > /dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nvm_default_install_dir() {
|
||||||
|
[ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm"
|
||||||
|
}
|
||||||
|
|
||||||
nvm_install_dir() {
|
nvm_install_dir() {
|
||||||
if [ -n "$NVM_DIR" ]; then
|
if [ -n "$NVM_DIR" ]; then
|
||||||
printf %s "${NVM_DIR}"
|
printf %s "${NVM_DIR}"
|
||||||
elif [ -n "$XDG_CONFIG_HOME" ]; then
|
|
||||||
printf %s "${XDG_CONFIG_HOME/nvm}"
|
|
||||||
else
|
else
|
||||||
printf %s "$HOME/.nvm"
|
nvm_default_install_dir
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm_latest_version() {
|
nvm_latest_version() {
|
||||||
echo "v0.34.0"
|
echo "v0.35.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm_profile_is_bash_or_zsh() {
|
nvm_profile_is_bash_or_zsh() {
|
||||||
@@ -45,14 +47,14 @@ nvm_source() {
|
|||||||
local NVM_SOURCE_URL
|
local NVM_SOURCE_URL
|
||||||
NVM_SOURCE_URL="$NVM_SOURCE"
|
NVM_SOURCE_URL="$NVM_SOURCE"
|
||||||
if [ "_$NVM_METHOD" = "_script-nvm-exec" ]; then
|
if [ "_$NVM_METHOD" = "_script-nvm-exec" ]; then
|
||||||
NVM_SOURCE_URL="https://raw.githubusercontent.com/creationix/nvm/$(nvm_latest_version)/nvm-exec"
|
NVM_SOURCE_URL="https://raw.githubusercontent.com/nvm-sh/nvm/$(nvm_latest_version)/nvm-exec"
|
||||||
elif [ "_$NVM_METHOD" = "_script-nvm-bash-completion" ]; then
|
elif [ "_$NVM_METHOD" = "_script-nvm-bash-completion" ]; then
|
||||||
NVM_SOURCE_URL="https://raw.githubusercontent.com/creationix/nvm/$(nvm_latest_version)/bash_completion"
|
NVM_SOURCE_URL="https://raw.githubusercontent.com/nvm-sh/nvm/$(nvm_latest_version)/bash_completion"
|
||||||
elif [ -z "$NVM_SOURCE_URL" ]; then
|
elif [ -z "$NVM_SOURCE_URL" ]; then
|
||||||
if [ "_$NVM_METHOD" = "_script" ]; then
|
if [ "_$NVM_METHOD" = "_script" ]; then
|
||||||
NVM_SOURCE_URL="https://raw.githubusercontent.com/creationix/nvm/$(nvm_latest_version)/nvm.sh"
|
NVM_SOURCE_URL="https://raw.githubusercontent.com/nvm-sh/nvm/$(nvm_latest_version)/nvm.sh"
|
||||||
elif [ "_$NVM_METHOD" = "_git" ] || [ -z "$NVM_METHOD" ]; then
|
elif [ "_$NVM_METHOD" = "_git" ] || [ -z "$NVM_METHOD" ]; then
|
||||||
NVM_SOURCE_URL="https://github.com/creationix/nvm.git"
|
NVM_SOURCE_URL="https://github.com/nvm-sh/nvm.git"
|
||||||
else
|
else
|
||||||
echo >&2 "Unexpected value \"$NVM_METHOD\" for \$NVM_METHOD"
|
echo >&2 "Unexpected value \"$NVM_METHOD\" for \$NVM_METHOD"
|
||||||
return 1
|
return 1
|
||||||
@@ -304,8 +306,17 @@ nvm_check_global_modules() {
|
|||||||
|
|
||||||
nvm_do_install() {
|
nvm_do_install() {
|
||||||
if [ -n "${NVM_DIR-}" ] && ! [ -d "${NVM_DIR}" ]; then
|
if [ -n "${NVM_DIR-}" ] && ! [ -d "${NVM_DIR}" ]; then
|
||||||
echo >&2 "You have \$NVM_DIR set to \"${NVM_DIR}\", but that directory does not exist. Check your profile files and environment."
|
if [ -e "${NVM_DIR}" ]; then
|
||||||
exit 1
|
echo >&2 "File \"${NVM_DIR}\" has the same name as installation directory."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${NVM_DIR}" = "$(nvm_default_install_dir)" ]; then
|
||||||
|
mkdir "${NVM_DIR}"
|
||||||
|
else
|
||||||
|
echo >&2 "You have \$NVM_DIR set to \"${NVM_DIR}\", but that directory does not exist. Check your profile files and environment."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
if [ -z "${METHOD}" ]; then
|
if [ -z "${METHOD}" ]; then
|
||||||
# Autodetect install method
|
# Autodetect install method
|
||||||
@@ -406,7 +417,7 @@ nvm_reset() {
|
|||||||
unset -f nvm_has nvm_install_dir nvm_latest_version nvm_profile_is_bash_or_zsh \
|
unset -f nvm_has nvm_install_dir nvm_latest_version nvm_profile_is_bash_or_zsh \
|
||||||
nvm_source nvm_node_version nvm_download install_nvm_from_git nvm_install_node \
|
nvm_source nvm_node_version nvm_download install_nvm_from_git nvm_install_node \
|
||||||
install_nvm_as_script nvm_try_profile nvm_detect_profile nvm_check_global_modules \
|
install_nvm_as_script nvm_try_profile nvm_detect_profile nvm_check_global_modules \
|
||||||
nvm_do_install nvm_reset
|
nvm_do_install nvm_reset nvm_default_install_dir
|
||||||
}
|
}
|
||||||
|
|
||||||
[ "_$NVM_ENV" = "_testing" ] || nvm_do_install
|
[ "_$NVM_ENV" = "_testing" ] || nvm_do_install
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nvm",
|
"name": "nvm",
|
||||||
"version": "0.34.0",
|
"version": "0.35.0",
|
||||||
"description": "Node Version Manager - Simple bash script to manage multiple active node.js versions",
|
"description": "Node Version Manager - Simple bash script to manage multiple active node.js versions",
|
||||||
"directories": {
|
"directories": {
|
||||||
"test": "test"
|
"test": "test"
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git://github.com/creationix/nvm.git"
|
"url": "git://github.com/nvm-sh/nvm.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"nvm",
|
"nvm",
|
||||||
@@ -32,9 +32,9 @@
|
|||||||
"author": "Tim Caswell <tim@creationix.com>",
|
"author": "Tim Caswell <tim@creationix.com>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/creationix/nvm/issues"
|
"url": "https://github.com/nvm-sh/nvm/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/creationix/nvm",
|
"homepage": "https://github.com/nvm-sh/nvm",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"dockerfile_lint": "^0.3.2",
|
"dockerfile_lint": "^0.3.2",
|
||||||
"eclint": "^2.6.0",
|
"eclint": "^2.6.0",
|
||||||
|
|||||||
@@ -29,8 +29,16 @@ make_fake_node() {
|
|||||||
VERSION="${1-}"
|
VERSION="${1-}"
|
||||||
[ -n "${VERSION}" ] || return 1
|
[ -n "${VERSION}" ] || return 1
|
||||||
|
|
||||||
|
local FORMATTED_VERSION
|
||||||
|
FORMATTED_VERSION="$(nvm_format_version "${VERSION}")"
|
||||||
|
|
||||||
local BIN_PATH
|
local BIN_PATH
|
||||||
BIN_PATH="$(nvm_version_path "${VERSION}")/bin"
|
BIN_PATH="$(nvm_version_path "${FORMATTED_VERSION}")/bin"
|
||||||
|
[ "${BIN_PATH}" != "/bin" ] || {
|
||||||
|
echo >&2 'nvm_version_path was empty'
|
||||||
|
return 5
|
||||||
|
}
|
||||||
|
|
||||||
mkdir -p "${BIN_PATH}" || {
|
mkdir -p "${BIN_PATH}" || {
|
||||||
echo >&2 'unable to make bin dir'
|
echo >&2 'unable to make bin dir'
|
||||||
return 2
|
return 2
|
||||||
@@ -40,6 +48,11 @@ make_fake_node() {
|
|||||||
echo >&2 'unable to make fake node bin'
|
echo >&2 'unable to make fake node bin'
|
||||||
return 3
|
return 3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nvm_is_version_installed "${FORMATTED_VERSION}" || {
|
||||||
|
echo >&2 'fake node is not installed'
|
||||||
|
return 4
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
make_fake_iojs() {
|
make_fake_iojs() {
|
||||||
@@ -47,8 +60,16 @@ make_fake_iojs() {
|
|||||||
VERSION="${1-}"
|
VERSION="${1-}"
|
||||||
[ -n "${VERSION}" ] || return 1
|
[ -n "${VERSION}" ] || return 1
|
||||||
|
|
||||||
|
local FORMATTED_VERSION
|
||||||
|
FORMATTED_VERSION="$(nvm_format_version "iojs-${VERSION}")"
|
||||||
|
|
||||||
local BIN_PATH
|
local BIN_PATH
|
||||||
BIN_PATH="$(nvm_version_path "iojs-${VERSION}")/bin"
|
BIN_PATH="$(nvm_version_path "${FORMATTED_VERSION}")/bin"
|
||||||
|
[ "${BIN_PATH}" != "/bin" ] || {
|
||||||
|
echo >&2 'nvm_version_path was empty'
|
||||||
|
return 5
|
||||||
|
}
|
||||||
|
|
||||||
mkdir -p "${BIN_PATH}" || {
|
mkdir -p "${BIN_PATH}" || {
|
||||||
echo >&2 'unable to make bin dir'
|
echo >&2 'unable to make bin dir'
|
||||||
return 2
|
return 2
|
||||||
@@ -62,6 +83,11 @@ make_fake_iojs() {
|
|||||||
echo >&2 'unable to make fake iojs bin'
|
echo >&2 'unable to make fake iojs bin'
|
||||||
return 3
|
return 3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nvm_is_version_installed "${FORMATTED_VERSION}" || {
|
||||||
|
echo >&2 'fake iojs is not installed'
|
||||||
|
return 4
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
watch() {
|
watch() {
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
\. ../../../nvm.sh
|
||||||
|
|
||||||
|
die () { echo "$@" ; exit 1; }
|
||||||
|
|
||||||
|
OUTPUT="$(nvm unalias node 2>&1)"
|
||||||
|
EXPECTED_OUTPUT="node is a default (built-in) alias and cannot be deleted."
|
||||||
|
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to remove a built-in alias should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
||||||
|
|
||||||
|
OUTPUT="$(nvm unalias stable 2>&1)"
|
||||||
|
EXPECTED_OUTPUT="stable is a default (built-in) alias and cannot be deleted."
|
||||||
|
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to remove a built-in alias should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
||||||
|
|
||||||
|
OUTPUT="$(nvm unalias unstable 2>&1)"
|
||||||
|
EXPECTED_OUTPUT="unstable is a default (built-in) alias and cannot be deleted."
|
||||||
|
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to remove a built-in alias should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
||||||
|
|
||||||
|
OUTPUT="$(nvm unalias iojs 2>&1)"
|
||||||
|
EXPECTED_OUTPUT="iojs is a default (built-in) alias and cannot be deleted."
|
||||||
|
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to remove a built-in alias should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
||||||
|
|
||||||
|
OUTPUT="$(nvm unalias system 2>&1)"
|
||||||
|
EXPECTED_OUTPUT="system is a default (built-in) alias and cannot be deleted."
|
||||||
|
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to remove a built-in alias should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
rmdir ../../../v0.0.2 >/dev/null 2>&1
|
rm -rf ../../../v0.0.2
|
||||||
rmdir ../../../v0.0.20 >/dev/null 2>&1
|
rm -rf ../../../v0.0.20
|
||||||
rmdir ../../../v0.12.0 >/dev/null 2>&1
|
rm -rf ../../../v0.12.0
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
\. ../../../nvm.sh
|
||||||
|
\. ../../common.sh
|
||||||
|
|
||||||
|
die () { echo "$@" ; unset -f nvm_ls nvm_list_aliases; exit 1; }
|
||||||
|
|
||||||
|
make_fake_node v0.12.87 || die 'fake v0.12.87 could not be made'
|
||||||
|
make_fake_node v0.12.9 || die 'fake v0.12.9 could not be made'
|
||||||
|
make_fake_iojs v0.1.2 || die 'fake iojs-v0.1.2 could not be made'
|
||||||
|
make_fake_iojs v0.10.2 || die 'fake iojs-v0.10.2 could not be made'
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
nvm_list_aliases() {
|
||||||
|
echo 'sd-6'
|
||||||
|
}
|
||||||
|
# sanity check
|
||||||
|
OUTPUT="$(nvm alias)"
|
||||||
|
EXPECTED_OUTPUT='sd-6'
|
||||||
|
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "1: expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"
|
||||||
|
|
||||||
|
nvm_ls() {
|
||||||
|
echo v0.12.87
|
||||||
|
echo v0.12.9
|
||||||
|
echo iojs-v0.1.2
|
||||||
|
echo iojs-v0.10.2
|
||||||
|
}
|
||||||
|
OUTPUT="$(nvm ls --no-colors --no-alias)"
|
||||||
|
EXPECTED_OUTPUT=" v0.12.87 *
|
||||||
|
v0.12.9 *
|
||||||
|
iojs-v0.1.2 *
|
||||||
|
iojs-v0.10.2 *"
|
||||||
|
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "2: expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"
|
||||||
15
test/fast/Listing versions/Running "nvm ls --no-alias" with a pattern errors
Executable file
15
test/fast/Listing versions/Running "nvm ls --no-alias" with a pattern errors
Executable file
@@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
\. ../../../nvm.sh
|
||||||
|
\. ../../common.sh
|
||||||
|
|
||||||
|
die () { echo "$@" ; unset -f nvm_ls nvm_list_aliases; exit 1; }
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
OUTPUT="$(nvm ls --no-colors --no-alias pattern 2>&1 ||:)"
|
||||||
|
EXPECTED_OUTPUT='`--no-alias` is not supported when a pattern is provided.'
|
||||||
|
EXIT_CODE="$(nvm ls --no-colors --no-alias pattern >/dev/null 2>&1 || echo $?)"
|
||||||
|
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"
|
||||||
|
|
||||||
|
[ "${EXIT_CODE}" = 55 ] || die "expected 55; got >${EXIT_CODE}<"
|
||||||
35
test/fast/Listing versions/Running "nvm ls" calls into nvm_alias
Executable file
35
test/fast/Listing versions/Running "nvm ls" calls into nvm_alias
Executable file
@@ -0,0 +1,35 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
\. ../../../nvm.sh
|
||||||
|
\. ../../common.sh
|
||||||
|
|
||||||
|
die () { echo "$@" ; unset -f nvm_ls nvm_list_aliases; exit 1; }
|
||||||
|
|
||||||
|
make_fake_node v0.12.87 || die 'fake v0.12.87 could not be made'
|
||||||
|
make_fake_node v0.12.9 || die 'fake v0.12.9 could not be made'
|
||||||
|
make_fake_iojs v0.1.2 || die 'fake iojs-v0.1.2 could not be made'
|
||||||
|
make_fake_iojs v0.10.2 || die 'fake iojs-v0.10.2 could not be made'
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
nvm_list_aliases() {
|
||||||
|
echo 'sd-6'
|
||||||
|
}
|
||||||
|
# sanity check
|
||||||
|
OUTPUT="$(nvm alias)"
|
||||||
|
EXPECTED_OUTPUT='sd-6'
|
||||||
|
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "1: expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"
|
||||||
|
|
||||||
|
nvm_ls() {
|
||||||
|
echo v0.12.87
|
||||||
|
echo v0.12.9
|
||||||
|
echo iojs-v0.1.2
|
||||||
|
echo iojs-v0.10.2
|
||||||
|
}
|
||||||
|
OUTPUT="$(nvm ls --no-colors)"
|
||||||
|
EXPECTED_OUTPUT=" v0.12.87 *
|
||||||
|
v0.12.9 *
|
||||||
|
iojs-v0.1.2 *
|
||||||
|
iojs-v0.10.2 *
|
||||||
|
sd-6"
|
||||||
|
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "2: expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"
|
||||||
@@ -25,3 +25,20 @@ nvm ls | grep v0.3.3 >/dev/null || die "v0.3.3 not found in: $(nvm ls)"
|
|||||||
nvm ls | grep v0.3.9 >/dev/null || die "v0.3.9 not found in: $(nvm ls)"
|
nvm ls | grep v0.3.9 >/dev/null || die "v0.3.9 not found in: $(nvm ls)"
|
||||||
nvm ls | grep v0.12.87 >/dev/null || die "v0.12.87 not found in: $(nvm ls)"
|
nvm ls | grep v0.12.87 >/dev/null || die "v0.12.87 not found in: $(nvm ls)"
|
||||||
nvm ls | grep iojs-v0.1.2 >/dev/null || die "iojs-v0.1.2 not found in: $(nvm ls)"
|
nvm ls | grep iojs-v0.1.2 >/dev/null || die "iojs-v0.1.2 not found in: $(nvm ls)"
|
||||||
|
|
||||||
|
OUTPUT="$(nvm_ls)"
|
||||||
|
EXPECTED_OUTPUT="v0.0.1
|
||||||
|
v0.0.3
|
||||||
|
v0.0.9
|
||||||
|
iojs-v0.1.2
|
||||||
|
v0.3.1
|
||||||
|
v0.3.3
|
||||||
|
v0.3.9
|
||||||
|
iojs-v0.10.2
|
||||||
|
v0.12.9
|
||||||
|
v0.12.87"
|
||||||
|
if nvm_has_system_node || nvm_has_system_iojs; then
|
||||||
|
EXPECTED_OUTPUT="${EXPECTED_OUTPUT}
|
||||||
|
system"
|
||||||
|
fi
|
||||||
|
[ "${OUTPUT-}" = "${EXPECTED_OUTPUT-}" ] || die "expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"
|
||||||
|
|||||||
23
test/fast/Listing versions/Running "nvm ls" with nounset should not fail.
Executable file
23
test/fast/Listing versions/Running "nvm ls" with nounset should not fail.
Executable file
@@ -0,0 +1,23 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo "$@" ; exit 1; }
|
||||||
|
|
||||||
|
\. ../../../nvm.sh
|
||||||
|
\. ../../common.sh
|
||||||
|
|
||||||
|
make_fake_node v0.12.34 || die 'fake v0.12.34 could not be made'
|
||||||
|
|
||||||
|
# Enable no unset variable
|
||||||
|
set -u
|
||||||
|
|
||||||
|
# Try an alias that does not exist
|
||||||
|
output=$(nvm ls 99 2>&1 1>/dev/null || true)
|
||||||
|
test -z "${output}" || die "1: expected empty; got >${output}"
|
||||||
|
|
||||||
|
# Try a version that does not exist
|
||||||
|
output=$(nvm ls 0.12.00 2>&1 1>/dev/null || true)
|
||||||
|
test -z "${output}" || die "2: expected empty; got >${output}"
|
||||||
|
|
||||||
|
# Try a version that does exist
|
||||||
|
output=$(nvm ls 0.12.34 2>&1 1>/dev/null || true)
|
||||||
|
test -z "${output}" || die "3: expected empty; got >${output}"
|
||||||
@@ -1,17 +1,16 @@
|
|||||||
rmdir ../../../v0.0.1 >/dev/null 2>&1
|
rm -rf ../../../v0.0.1
|
||||||
rmdir ../../../v0.0.2 >/dev/null 2>&1
|
rm -rf ../../../v0.0.2
|
||||||
rmdir ../../../v0.0.3 >/dev/null 2>&1
|
rm -rf ../../../v0.0.3
|
||||||
rmdir ../../../v0.0.9 >/dev/null 2>&1
|
rm -rf ../../../v0.0.9
|
||||||
rmdir ../../../v0.0.20 >/dev/null 2>&1
|
rm -rf ../../../v0.0.20
|
||||||
rmdir ../../../v0.1.2 >/dev/null 2>&1
|
rm -rf ../../../v0.1.2
|
||||||
rmdir ../../../v0.1.3 >/dev/null 2>&1
|
rm -rf ../../../v0.1.3
|
||||||
rmdir ../../../v0.1.4 >/dev/null 2>&1
|
rm -rf ../../../v0.1.4
|
||||||
rmdir ../../../v0.2.3 >/dev/null 2>&1
|
rm -rf ../../../v0.2.3
|
||||||
rmdir ../../../v0.3.1 >/dev/null 2>&1
|
rm -rf ../../../v0.3.1
|
||||||
rmdir ../../../v0.3.3 >/dev/null 2>&1
|
rm -rf ../../../v0.3.3
|
||||||
rmdir ../../../v0.3.9 >/dev/null 2>&1
|
rm -rf ../../../v0.3.9
|
||||||
rmdir ../../../v0.20.3 >/dev/null 2>&1
|
rm -rf ../../../v0.20.3
|
||||||
rmdir ../../../versions >/dev/null 2>&1
|
rm -rf ../../../versions
|
||||||
unalias nvm_has_system_node >/dev/null 2>&1
|
rm -f ../../../alias/stable
|
||||||
rm -f ../../../alias/stable >/dev/null 2>&1
|
rm -f ../../../alias/unstable
|
||||||
rm -f ../../../alias/unstable >/dev/null 2>&1
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ 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 "
|
[ "$NEW_PATH" = "$NVM_DIR/v0.1.2/bin" ] || die "Not correctly prepended: $NEW_PATH "
|
||||||
|
|
||||||
|
|
||||||
# https://github.com/creationix/nvm/issues/1652#issuecomment-342571223
|
# https://github.com/nvm-sh/nvm/issues/1652#issuecomment-342571223
|
||||||
MAC_OS_NESTED_SESSION_PATH=/usr/bin:/usr/local/bin:$NVM_DIR/versions/node/v4.5.0/bin
|
MAC_OS_NESTED_SESSION_PATH=/usr/bin:/usr/local/bin:$NVM_DIR/versions/node/v4.5.0/bin
|
||||||
|
|
||||||
# New version dir
|
# New version dir
|
||||||
|
|||||||
@@ -46,9 +46,13 @@ WGET_EXPECTED_INFO="$(type wget)"
|
|||||||
cleanup
|
cleanup
|
||||||
|
|
||||||
# 4. nvm_command_info() should not have standard error
|
# 4. nvm_command_info() should not have standard error
|
||||||
nvm_command_info ls 2>&1 >/dev/null | grep . && die "\`nvm_command_info ls\` should not return standard error message(stage 4)"
|
OUTPUT="$(nvm_command_info ls 2>&1 >/dev/null)"
|
||||||
nvm_command_info rm 2>&1 >/dev/null | grep . && die "\`nvm_command_info rm\` should not return standard error message(stage 4)"
|
[ -z "${OUTPUT}" ] || die "\`nvm_command_info ls\` expected no stderr; got >${OUTPUT}< (stage 4)"
|
||||||
nvm_command_info git 2>&1 >/dev/null | grep . && die "\`nvm_command_info git\` should not return standard error message(stage 4)"
|
OUTPUT="$(nvm_command_info rm 2>&1 >/dev/null)"
|
||||||
nvm_command_info grep 2>&1 >/dev/null | grep . && die "\`nvm_command_info grep\` should not return standard error message(stage 4)"
|
[ -z "${OUTPUT}" ] || die "\`nvm_command_info rm\` expected no stderr; got >${OUTPUT}< (stage 4)"
|
||||||
|
OUTPUT="$(nvm_command_info git 2>&1 >/dev/null)"
|
||||||
|
[ -z "${OUTPUT}" ] || die "\`nvm_command_info git\` expected no stderr; got >${OUTPUT}< (stage 4)"
|
||||||
|
OUTPUT="$(nvm_command_info grep 2>&1 >/dev/null)"
|
||||||
|
[ -z "${OUTPUT}" ] || die "\`nvm_command_info grep\` expected no stderr; got >${OUTPUT}< (stage 4)"
|
||||||
|
|
||||||
cleanup
|
cleanup
|
||||||
|
|||||||
91
test/fast/Unit tests/nvm_get_default_packages
Executable file
91
test/fast/Unit tests/nvm_get_default_packages
Executable file
@@ -0,0 +1,91 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
FILE="$NVM_DIR/default-packages"
|
||||||
|
\. ../../../nvm.sh
|
||||||
|
|
||||||
|
die () { echo "$@" ; cleanup ; exit 1; }
|
||||||
|
setup () {
|
||||||
|
if [ -f $FILE ]; then
|
||||||
|
ORIG_DEFAULT_PACKAGES=$(cat $FILE)
|
||||||
|
mkdir -p ./tmp/ ||:
|
||||||
|
mv $FILE ./tmp/default-packages ||:
|
||||||
|
fi
|
||||||
|
touch $FILE
|
||||||
|
}
|
||||||
|
cleanup () {
|
||||||
|
if [ "$ORIG_DEFAULT_PACKAGES" != "" ]; then
|
||||||
|
rm -rf ./tmp/
|
||||||
|
echo "$ORIG_DEFAULT_PACKAGES" > $FILE
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
setup
|
||||||
|
|
||||||
|
cat > $FILE << EOF
|
||||||
|
rimraf
|
||||||
|
object-inspect@1.0.2
|
||||||
|
|
||||||
|
# commented-package
|
||||||
|
|
||||||
|
stevemao/left-pad
|
||||||
|
EOF
|
||||||
|
|
||||||
|
DEFAULT_PKGS="$(nvm_get_default_packages)"
|
||||||
|
EXPECTED_PKGS='rimraf object-inspect@1.0.2 stevemao/left-pad'
|
||||||
|
[ "${DEFAULT_PKGS}" = "${EXPECTED_PKGS}" ] || die "1: expected default packages >${EXPECTED_PKGS}<; got >${DEFAULT_PKGS}<"
|
||||||
|
|
||||||
|
cleanup
|
||||||
|
|
||||||
|
setup
|
||||||
|
|
||||||
|
cat > $FILE << EOF
|
||||||
|
rimraf
|
||||||
|
not~a~package~name
|
||||||
|
mkdirp
|
||||||
|
EOF
|
||||||
|
|
||||||
|
DEFAULT_PKGS="$(nvm_get_default_packages)"
|
||||||
|
EXPECTED_PKGS='rimraf not~a~package~name mkdirp'
|
||||||
|
[ "${DEFAULT_PKGS}" = "${EXPECTED_PKGS}" ] || die "2: expected default packages >${EXPECTED_PKGS}<; got >${DEFAULT_PKGS}<"
|
||||||
|
|
||||||
|
cleanup
|
||||||
|
|
||||||
|
setup
|
||||||
|
|
||||||
|
cat > $FILE << EOF
|
||||||
|
rimraf
|
||||||
|
not~a~package~name
|
||||||
|
mkdirp
|
||||||
|
EOF
|
||||||
|
printf %s "$(cat "${FILE}")" > $FILE # strip trailing newline
|
||||||
|
|
||||||
|
DEFAULT_PKGS="$(nvm_get_default_packages)"
|
||||||
|
EXPECTED_PKGS='rimraf not~a~package~name mkdirp'
|
||||||
|
[ "${DEFAULT_PKGS}" = "${EXPECTED_PKGS}" ] || die "3: expected default packages >${EXPECTED_PKGS}<; got >${DEFAULT_PKGS}<"
|
||||||
|
|
||||||
|
cleanup
|
||||||
|
|
||||||
|
setup
|
||||||
|
|
||||||
|
cat > $FILE << EOF
|
||||||
|
object-inspect @ 1.0.2
|
||||||
|
rimraf
|
||||||
|
EOF
|
||||||
|
|
||||||
|
DEFAULT_PKGS="$(nvm_get_default_packages 2>&1 >/dev/null)"
|
||||||
|
EXPECTED_PKGS="Only one package per line is allowed in the $FILE file. Please remove any lines with multiple space-separated values."
|
||||||
|
[ "${DEFAULT_PKGS}" = "${EXPECTED_PKGS}" ] || die "4: expected default packages >${EXPECTED_PKGS}<; got >${DEFAULT_PKGS}<"
|
||||||
|
|
||||||
|
cleanup
|
||||||
|
|
||||||
|
setup
|
||||||
|
|
||||||
|
rm -rf $FILE
|
||||||
|
|
||||||
|
DEFAULT_PKGS="$(nvm_get_default_packages)"
|
||||||
|
EXPECTED_PKGS=''
|
||||||
|
[ "${DEFAULT_PKGS}" = "${EXPECTED_PKGS}" ] || die "5: expected default packages >${EXPECTED_PKGS}<; got >${DEFAULT_PKGS}<"
|
||||||
|
|
||||||
|
touch $FILE
|
||||||
|
|
||||||
|
cleanup
|
||||||
32
test/fast/Unit tests/nvm_stdout_is_terminal
Executable file
32
test/fast/Unit tests/nvm_stdout_is_terminal
Executable file
@@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
tempfile=$(mktemp)
|
||||||
|
|
||||||
|
die () { echo "$@" ; cleanup; exit 1; }
|
||||||
|
cleanup() { rm -f "$tempfile"; }
|
||||||
|
|
||||||
|
\. ../../../nvm.sh
|
||||||
|
|
||||||
|
if [ -t 1 ] ; then
|
||||||
|
# test is running in a terminal, e.g. locally
|
||||||
|
nvm_stdout_is_terminal || die 'nvm_stdout_is_terminal should be true'
|
||||||
|
nvm_stdout_is_terminal 2>/dev/null || die 'nvm_stdout_is_terminal should be true when stderr is redirected'
|
||||||
|
nvm_stdout_is_terminal </dev/null || die 'nvm_stdout_is_terminal should be true when stdin is redirected'
|
||||||
|
else
|
||||||
|
# test is not running in a terminal, e.g. on travis-ci
|
||||||
|
! nvm_stdout_is_terminal || die 'nvm_stdout_is_terminal should be false'
|
||||||
|
! nvm_stdout_is_terminal 2>/dev/null || die 'nvm_stdout_is_terminal should be false when stderr is redirected'
|
||||||
|
! nvm_stdout_is_terminal </dev/null || die 'nvm_stdout_is_terminal should be false when stdin is redirected'
|
||||||
|
fi
|
||||||
|
|
||||||
|
(! nvm_stdout_is_terminal || echo "boo!") | read && die 'nvm_stdout_is_terminal should be false when stdout goes to a pipe'
|
||||||
|
! nvm_stdout_is_terminal >/dev/null || die 'nvm_stdout_is_terminal should be false when stdout goes to /dev/null'
|
||||||
|
! nvm_stdout_is_terminal >"$tempfile" || die 'nvm_stdout_is_terminal should be false when stdout goes to a file'
|
||||||
|
[ "$(nvm_stdout_is_terminal; echo $?)" = "1" ] || die 'nvm_stdout_is_terminal should be false in command substitution'
|
||||||
|
|
||||||
|
# also test the 'true' case while running on travis-ci or similar environments
|
||||||
|
nvm_stdout_is_terminal >/dev/tty || die 'nvm_stdout_is_terminal should be true when stdout goes to /dev/tty'
|
||||||
|
nvm_stdout_is_terminal >/dev/tty 2>/dev/null || die 'nvm_stdout_is_terminal should be true when stdout goes to /dev/tty and stderr is redirected'
|
||||||
|
nvm_stdout_is_terminal >/dev/tty </dev/null || die 'nvm_stdout_is_terminal should be true when stdout goes to /dev/tty and stdin is redirected'
|
||||||
|
|
||||||
|
cleanup
|
||||||
27
test/fast/Unit tests/nvm_supports_source_options
Executable file
27
test/fast/Unit tests/nvm_supports_source_options
Executable file
@@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo "$@" ; exit 1; }
|
||||||
|
|
||||||
|
\. ../../../nvm.sh
|
||||||
|
|
||||||
|
x=0
|
||||||
|
i=0
|
||||||
|
runs=5
|
||||||
|
calls=500
|
||||||
|
first_result=false
|
||||||
|
if (nvm_supports_source_options && printf .); then
|
||||||
|
first_result=true
|
||||||
|
fi
|
||||||
|
while [ $x -le $runs ]; do
|
||||||
|
y=$x
|
||||||
|
x=$(( x + 1 ))
|
||||||
|
while [ $i -le $calls ]; do
|
||||||
|
this_result=false
|
||||||
|
if (nvm_supports_source_options && printf .); then
|
||||||
|
this_result=true
|
||||||
|
fi
|
||||||
|
[ $this_result = $first_result ] || die "call ${i}, run ${y} got ${this_result}; expected ${first_result}"
|
||||||
|
i=$(( i + 1 ))
|
||||||
|
done
|
||||||
|
done
|
||||||
|
echo "${runs} runs of ${calls} calls succeeded"
|
||||||
@@ -9,9 +9,13 @@ NVM_PREFIXED_TEST_VERSION="iojs-$NVM_TEST_VERSION"
|
|||||||
|
|
||||||
# Remove the stuff we're clobbering.
|
# Remove the stuff we're clobbering.
|
||||||
[ -e "${NVM_DIR}/versions/io.js/${NVM_TEST_VERSION}" ] && rm -R "${NVM_DIR}/versions/io.js/${NVM_TEST_VERSION}"
|
[ -e "${NVM_DIR}/versions/io.js/${NVM_TEST_VERSION}" ] && rm -R "${NVM_DIR}/versions/io.js/${NVM_TEST_VERSION}"
|
||||||
|
[ -e "${NVM_DIR}/.cache/bin/${NVM_TEST_VERSION}-linux-x64/" ] && rm -R "${NVM_DIR}/.cache/bin/${NVM_TEST_VERSION}-linux-x64/"
|
||||||
|
|
||||||
# Install from binary
|
# Install from binary
|
||||||
nvm install $NVM_PREFIXED_TEST_VERSION || die "install $NVM_PREFIXED_TEST_VERSION failed"
|
OUTPUT_HEAD="$(2>&1 nvm install --no-progress $NVM_PREFIXED_TEST_VERSION | tac | tail -n 1)" || die "install $NVM_PREFIXED_TEST_VERSION failed"
|
||||||
|
EXPECTED_OUTPUT_HEAD="Downloading and installing io.js v1.0.0..."
|
||||||
|
|
||||||
|
[ "${OUTPUT_HEAD}" = "${EXPECTED_OUTPUT_HEAD}" ] || die "expected >${EXPECTED_OUTPUT_HEAD}<; got >${OUTPUT_HEAD}<"
|
||||||
|
|
||||||
# Check
|
# Check
|
||||||
[ -d "${NVM_DIR}/versions/io.js/${NVM_TEST_VERSION}" ]
|
[ -d "${NVM_DIR}/versions/io.js/${NVM_TEST_VERSION}" ]
|
||||||
|
|||||||
@@ -9,11 +9,11 @@ NVM_PREFIXED_TEST_VERSION="$(nvm ls-remote "$NVM_VERSION" | tail -1 | sed 's/^[
|
|||||||
NVM_TEST_VERSION="$(nvm_strip_iojs_prefix "$NVM_PREFIXED_TEST_VERSION")"
|
NVM_TEST_VERSION="$(nvm_strip_iojs_prefix "$NVM_PREFIXED_TEST_VERSION")"
|
||||||
|
|
||||||
# Remove the stuff we're clobbering.
|
# Remove the stuff we're clobbering.
|
||||||
[ -e ../../$NVM_TEST_VERSION ] && rm -R ../../$NVM_TEST_VERSION
|
[ -e "../../$NVM_TEST_VERSION" ] && rm -R "../../$NVM_TEST_VERSION"
|
||||||
|
|
||||||
# Install from binary
|
# Install from binary
|
||||||
nvm install "$NVM_VERSION" || die "nvm install $NVM_VERSION failed"
|
nvm install "$NVM_VERSION" || die "nvm install $NVM_VERSION failed"
|
||||||
|
|
||||||
# Check
|
# Check
|
||||||
[ -d "${NVM_DIR}/versions/io.js/$NVM_TEST_VERSION" ]
|
[ -d "${NVM_DIR}/versions/io.js/$NVM_TEST_VERSION" ]
|
||||||
nvm run $NVM_PREFIXED_TEST_VERSION --version | grep $NVM_TEST_VERSION || die "'nvm run $NVM_PREFIXED_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed"
|
nvm run "$NVM_PREFIXED_TEST_VERSION" --version | grep "$NVM_TEST_VERSION" || die "'nvm run $NVM_PREFIXED_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed"
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ cleanup () {
|
|||||||
|
|
||||||
setup
|
setup
|
||||||
|
|
||||||
\. ../../../nvm.sh
|
\. ../../nvm.sh
|
||||||
|
|
||||||
cat > $FILE << EOF
|
cat > $FILE << EOF
|
||||||
rimraf
|
rimraf
|
||||||
@@ -30,8 +30,11 @@ object-inspect@1.0.2
|
|||||||
# commented-package
|
# commented-package
|
||||||
|
|
||||||
stevemao/left-pad
|
stevemao/left-pad
|
||||||
|
daytime
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
printf %s "$(cat "${FILE}")" > $FILE # strip trailing newline
|
||||||
|
|
||||||
nvm install v6.10.1 2>&1
|
nvm install v6.10.1 2>&1
|
||||||
EXIT_CODE=$?
|
EXIT_CODE=$?
|
||||||
[ "_$EXIT_CODE" = "_0" ] || die "expected 'nvm install v6.10.1' to exit with 0, got $EXIT_CODE"
|
[ "_$EXIT_CODE" = "_0" ] || die "expected 'nvm install v6.10.1' to exit with 0, got $EXIT_CODE"
|
||||||
@@ -41,11 +44,16 @@ if [ -z "$?" ]; then
|
|||||||
die "expected 'nvm exec v6.10.1 npm ls -g --depth=0 | grep -q 'rimraf'' to exit with 0, got $?"
|
die "expected 'nvm exec v6.10.1 npm ls -g --depth=0 | grep -q 'rimraf'' to exit with 0, got $?"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
nvm exec v6.10.1 npm ls -g --depth=0 | grep -q 'daytime'
|
||||||
|
if [ -z "$?" ]; then
|
||||||
|
die "expected 'nvm exec v6.10.1 npm ls -g --depth=0 | grep -q 'daytime'' to exit with 0, got $?"
|
||||||
|
fi
|
||||||
|
|
||||||
cleanup
|
cleanup
|
||||||
|
|
||||||
setup
|
setup
|
||||||
|
|
||||||
\. ../../../nvm.sh
|
\. ../../nvm.sh
|
||||||
|
|
||||||
cat > $FILE << EOF
|
cat > $FILE << EOF
|
||||||
rimraf
|
rimraf
|
||||||
@@ -20,7 +20,7 @@ nvm ls | grep "$NVM_TEST_VERSION" || die "Failed to install node"
|
|||||||
# Switch to another version so we can uninstall
|
# Switch to another version so we can uninstall
|
||||||
nvm use 0.12.7
|
nvm use 0.12.7
|
||||||
|
|
||||||
# if zsh, set "nomatch" opt to reproduce failure from https://github.com/creationix/nvm/issues/1228
|
# if zsh, set "nomatch" opt to reproduce failure from https://github.com/nvm-sh/nvm/issues/1228
|
||||||
if nvm_has "setopt"; then
|
if nvm_has "setopt"; then
|
||||||
setopt nomatch
|
setopt nomatch
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ nvm ls | grep "$NVM_TEST_VERSION" || die "Failed to install node"
|
|||||||
|
|
||||||
# Install global module as root
|
# Install global module as root
|
||||||
npm_path=$(which npm)
|
npm_path=$(which npm)
|
||||||
sudo -n "$npm_path" install jspm -g || die 'either sudo failed, or `npm install jspm -g` failed`'
|
sudo -n "$npm_path" install jspm@'<2' -g || die 'either sudo failed, or `npm install jspm -g` failed`'
|
||||||
|
|
||||||
# Switch to another version so we can uninstall
|
# Switch to another version so we can uninstall
|
||||||
nvm use 0.12.7
|
nvm use 0.12.7
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ cleanup() {
|
|||||||
\. ../../../nvm.sh
|
\. ../../../nvm.sh
|
||||||
|
|
||||||
EXPECTED_VERSION="v12.3.456"
|
EXPECTED_VERSION="v12.3.456"
|
||||||
URL="https://github.com/creationix/nvm/releases/tag/$EXPECTED_VERSION"
|
URL="https://github.com/nvm-sh/nvm/releases/tag/$EXPECTED_VERSION"
|
||||||
EXPECTED_CURL_ARGS="--compressed -q -w %{url_effective}\n -L -s -S http://latest.nvm.sh -o /dev/null"
|
EXPECTED_CURL_ARGS="--compressed -q -w %{url_effective}\n -L -s -S http://latest.nvm.sh -o /dev/null"
|
||||||
EXPECTED_WGET_ARGS="-q http://latest.nvm.sh --server-response -O /dev/null"
|
EXPECTED_WGET_ARGS="-q http://latest.nvm.sh --server-response -O /dev/null"
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ wget() {
|
|||||||
local WGET_CONTENTS
|
local WGET_CONTENTS
|
||||||
WGET_CONTENTS="
|
WGET_CONTENTS="
|
||||||
HTTP/1.1 301 Moved Permanently
|
HTTP/1.1 301 Moved Permanently
|
||||||
Location: https://github.com/creationix/nvm/releases/latest
|
Location: https://github.com/nvm-sh/nvm/releases/latest
|
||||||
Content-Type: text/html; charset=utf-8
|
Content-Type: text/html; charset=utf-8
|
||||||
Content-Length: 84
|
Content-Length: 84
|
||||||
Date: Mon, 22 Dec 2014 02:11:15 GMT
|
Date: Mon, 22 Dec 2014 02:11:15 GMT
|
||||||
|
|||||||
Reference in New Issue
Block a user