Compare commits
64 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
661a702cdd | ||
|
|
510b2fd44c | ||
|
|
80a4e06af9 | ||
|
|
22902f04a3 | ||
|
|
6848c16d53 | ||
|
|
3abb98124e | ||
|
|
21c0c05130 | ||
|
|
00af6341f7 | ||
|
|
11a9d22607 | ||
|
|
bbe032fa7e | ||
|
|
4054bd70ce | ||
|
|
499d303746 | ||
|
|
31bc0a13c2 | ||
|
|
c72f2c6f21 | ||
|
|
f2c5ce459a | ||
|
|
0f0d5e8270 | ||
|
|
e77ed07ccc | ||
|
|
e01060fa2c | ||
|
|
96069da0d5 | ||
|
|
4436638816 | ||
|
|
344cc32ac3 | ||
|
|
7929190e6e | ||
|
|
8debf39f24 | ||
|
|
c7ca08d575 | ||
|
|
6110d31969 | ||
|
|
68d2f47c0a | ||
|
|
6e0562ac6d | ||
|
|
68d331a816 | ||
|
|
22e07cc0c1 | ||
|
|
cf92956e5d | ||
|
|
1d88ecfce5 | ||
|
|
035bf9e28e | ||
|
|
f7fbad2bd6 | ||
|
|
19c55b9936 | ||
|
|
9dc6f3e4a5 | ||
|
|
1c00753fd9 | ||
|
|
b1200c659b | ||
|
|
16b75b7333 | ||
|
|
1bf567bd0b | ||
|
|
a01deb11dc | ||
|
|
a5aec107df | ||
|
|
18c6f98acc | ||
|
|
424aeb38b4 | ||
|
|
abfe0a5891 | ||
|
|
3561bbc54a | ||
|
|
83043c4d3a | ||
|
|
55eafcd814 | ||
|
|
06c3bf6a8f | ||
|
|
4b1100e515 | ||
|
|
f6d11bae41 | ||
|
|
d2d232ea2b | ||
|
|
7b3af45cf7 | ||
|
|
bac5393e12 | ||
|
|
2d4e877b61 | ||
|
|
6575b6b052 | ||
|
|
33fa27dabe | ||
|
|
91a55dd91a | ||
|
|
7aba64a2d5 | ||
|
|
dcc8059ef8 | ||
|
|
8e1e5df059 | ||
|
|
e0ed1eacfd | ||
|
|
73438e339e | ||
|
|
b02617028f | ||
|
|
f607f2f783 |
@@ -18,5 +18,11 @@ indent_size = false
|
||||
[test/fast/Listing versions/Running "nvm ls --no-alias" does not call into nvm_alias]
|
||||
indent_size = false
|
||||
|
||||
[test/fast/Unit tests/mocks/**]
|
||||
insert_final_newline = off
|
||||
|
||||
[test/**/.urchin*]
|
||||
insert_final_newline = off
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
|
||||
50
.github/workflows/latest-npm.yml
vendored
Normal file
50
.github/workflows/latest-npm.yml
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
name: 'Tests: `nvm install-latest-npm`'
|
||||
|
||||
on: [pull_request, push]
|
||||
|
||||
jobs:
|
||||
nodes:
|
||||
name: 'nvm install-latest-npm'
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version:
|
||||
- "11"
|
||||
- "10"
|
||||
- "9"
|
||||
- "9.2"
|
||||
- "9.1"
|
||||
- "9.0"
|
||||
- "8"
|
||||
- "7"
|
||||
- "6"
|
||||
- "6.1"
|
||||
- "5"
|
||||
- "5.9"
|
||||
- "4"
|
||||
- "4.6"
|
||||
- "4.5"
|
||||
- "4.4"
|
||||
- "3"
|
||||
- "2"
|
||||
- "1"
|
||||
- "0.12"
|
||||
- "0.10"
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: ljharb/actions/node/run@main
|
||||
name: 'nvm install-latest-npm'
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
skip-ls-check: true
|
||||
skip-install: true
|
||||
shell-command: 'npm --version'
|
||||
|
||||
node:
|
||||
name: 'nvm install-latest-npm'
|
||||
needs: [nodes]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: 'echo tests completed'
|
||||
38
.github/workflows/lint.yml
vendored
Normal file
38
.github/workflows/lint.yml
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
name: 'Tests: linting'
|
||||
|
||||
on: [pull_request, push]
|
||||
|
||||
jobs:
|
||||
eclint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: ljharb/actions/node/run@main
|
||||
name: 'npm install && npm run eclint'
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
command: 'eclint'
|
||||
|
||||
dockerfile_lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: ljharb/actions/node/run@main
|
||||
name: 'npm install && npm run dockerfile_lint'
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
command: 'dockerfile_lint'
|
||||
|
||||
doctoc:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: ljharb/actions/node/run@main
|
||||
name: 'npm install && npm run dockerfile_lint'
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
shell-command: |
|
||||
set -e
|
||||
cp README.md README.md.orig
|
||||
npm run doctoc
|
||||
diff -q README.md README.md.orig
|
||||
15
.github/workflows/rebase.yml
vendored
Normal file
15
.github/workflows/rebase.yml
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
name: Automatic Rebase
|
||||
|
||||
on: [pull_request_target]
|
||||
|
||||
jobs:
|
||||
_:
|
||||
name: "Automatic Rebase"
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: ljharb/rebase@master
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
24
.github/workflows/release.yml
vendored
Normal file
24
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
name: 'Tests: release process'
|
||||
|
||||
on: [pull_request, push]
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2-beta
|
||||
with:
|
||||
node-version: "14"
|
||||
- run: npm install
|
||||
- name: Configure git
|
||||
run: |
|
||||
git config user.name github-actions
|
||||
git config user.email github-actions@github.com
|
||||
git fetch --unshallow --tags || git fetch --tags
|
||||
- name: Attempt `make release` process
|
||||
run: echo proceed | make TAG=99.99.99 release
|
||||
env:
|
||||
GIT_EDITOR: "sed -i '1 s/^/99.99.99 make release test/'"
|
||||
- name: Ensure tag is created
|
||||
run: git tag | grep v99.99.99
|
||||
14
.github/workflows/require-allow-edits.yml
vendored
Normal file
14
.github/workflows/require-allow-edits.yml
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
name: Require “Allow Edits”
|
||||
|
||||
on: [pull_request_target]
|
||||
|
||||
jobs:
|
||||
_:
|
||||
name: "Require “Allow Edits”"
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: ljharb/require-allow-edits@main
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
31
.github/workflows/shellcheck.yml
vendored
Normal file
31
.github/workflows/shellcheck.yml
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
name: 'Tests: shellcheck'
|
||||
|
||||
on: [pull_request, push]
|
||||
|
||||
jobs:
|
||||
shellcheck:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
shell:
|
||||
- bash
|
||||
- sh
|
||||
- dash
|
||||
- ksh
|
||||
file:
|
||||
- nvm.sh
|
||||
include:
|
||||
- shell: bash
|
||||
file: install.sh # only supported on bash
|
||||
- shell: bash
|
||||
file: bash_completion # only needed in bash/zsh
|
||||
- shell: bash
|
||||
file: nvm-exec # only runs in bash
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install shellcheck
|
||||
run: brew install shellcheck
|
||||
- run: "shellcheck --version"
|
||||
- name: Run shellcheck on ${{ matrix.file }}
|
||||
run: shellcheck -s ${{ matrix.shell }} ${{ matrix.file }}
|
||||
29
.github/workflows/toc.yml
vendored
Normal file
29
.github/workflows/toc.yml
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
name: update readme TOC
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
_:
|
||||
name: "update readme TOC"
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
# https://github.com/actions/checkout/issues/217#issue-599945005
|
||||
# pulls all commits (needed for lerna / semantic release to correctly version)
|
||||
fetch-depth: "0"
|
||||
|
||||
# pulls all tags (needed for lerna / semantic release to correctly version)
|
||||
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: '12.x'
|
||||
- run: npm install
|
||||
- run: npm run doctoc
|
||||
- name: commit changes
|
||||
uses: ljharb/actions-js-build/commit@v3+amendpush
|
||||
with:
|
||||
amend: true
|
||||
force: true
|
||||
26
.travis.yml
26
.travis.yml
@@ -1,6 +1,5 @@
|
||||
language: generic
|
||||
dist: xenial
|
||||
sudo: required
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@@ -19,21 +18,13 @@ before_install:
|
||||
- $SHELL --version 2> /dev/null || dpkg -s $SHELL 2> /dev/null || which $SHELL
|
||||
- curl --version
|
||||
- wget --version
|
||||
- shellcheck --version
|
||||
install:
|
||||
- if [ -z "${SHELLCHECK-}" ]; then nvm install node && npm install && npm prune && npm ls urchin doctoc eclint dockerfile_lint; fi
|
||||
- '[ -z "$WITHOUT_CURL" ] || sudo apt-get remove curl -y'
|
||||
script:
|
||||
- if [ -n "${MAKE_RELEASE-}" ]; then export GIT_EDITOR="sed -i '1 s/^/99.99.99 make release test/'" && git fetch --unshallow --tags && echo proceed | make TAG=99.99.99 release ; fi
|
||||
- if [ -n "${DOCTOCCHECK-}" ]; then cp README.md README.md.orig && npm run doctoc && diff -q README.md README.md.orig ; fi
|
||||
- if [ -n "${ECLINT-}" ]; then npm run eclint ; fi
|
||||
- if [ -n "${DOCKERFILE_LINT-}" ]; then npm run dockerfile_lint ; 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 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
|
||||
- if [ -n "${NODE-}" ]; then . nvm.sh && set -ex && nvm install --latest-npm "${NODE}" && npm --version; fi
|
||||
env:
|
||||
global:
|
||||
- CXX=g++
|
||||
@@ -42,11 +33,6 @@ env:
|
||||
- PATH="/usr/lib/ccache/:$PATH"
|
||||
- NVM_DIR="${TRAVIS_BUILD_DIR}"
|
||||
matrix:
|
||||
- MAKE_RELEASE=true
|
||||
- DOCTOCCHECK=true
|
||||
- SHELLCHECK=true
|
||||
- ECLINT=true
|
||||
- DOCKERFILE_LINT=true
|
||||
- SHELL=bash TEST_SUITE=install_script
|
||||
- SHELL=sh TEST_SUITE=fast
|
||||
- SHELL=dash TEST_SUITE=fast
|
||||
@@ -83,15 +69,3 @@ env:
|
||||
- SHELL=zsh TEST_SUITE=installation_iojs WITHOUT_CURL=1
|
||||
# - SHELL=ksh TEST_SUITE=installation_iojs
|
||||
# - SHELL=ksh TEST_SUITE=installation_iojs WITHOUT_CURL=1
|
||||
- NODE=10 TEST="nvm install-latest-npm"
|
||||
- NODE=9 TEST="nvm install-latest-npm"
|
||||
- NODE=8 TEST="nvm install-latest-npm"
|
||||
- NODE=7 TEST="nvm install-latest-npm"
|
||||
- NODE=6 TEST="nvm install-latest-npm"
|
||||
- NODE=5 TEST="nvm install-latest-npm"
|
||||
- NODE=5.9 TEST="nvm install-latest-npm"
|
||||
- NODE=4 TEST="nvm install-latest-npm"
|
||||
- NODE=4.6 TEST="nvm install-latest-npm"
|
||||
- NODE=4.5 TEST="nvm install-latest-npm"
|
||||
- NODE=4.4 TEST="nvm install-latest-npm"
|
||||
- NODE=2 TEST="nvm install-latest-npm"
|
||||
|
||||
16
Dockerfile
16
Dockerfile
@@ -6,9 +6,7 @@
|
||||
# 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
|
||||
FROM ubuntu:16.04
|
||||
LABEL maintainer="Peter Dave Hello <hsu@peterdavehello.org>"
|
||||
LABEL name="nvm-dev-env"
|
||||
LABEL version="latest"
|
||||
@@ -20,7 +18,7 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
|
||||
# ShellCheck version
|
||||
ENV SHELLCHECK_VERSION=0.6.0
|
||||
ENV SHELLCHECK_VERSION=0.7.0
|
||||
|
||||
# Pick a Ubuntu apt mirror site for better speed
|
||||
# ref: https://launchpad.net/ubuntu/+archivemirrors
|
||||
@@ -43,6 +41,7 @@ RUN apt update && \
|
||||
file \
|
||||
openssl \
|
||||
libssl-dev \
|
||||
locales \
|
||||
ca-certificates \
|
||||
ssh \
|
||||
wget \
|
||||
@@ -65,14 +64,11 @@ RUN apt update && \
|
||||
bash-completion && \
|
||||
apt-get clean
|
||||
|
||||
# ShellCheck with Ubuntu 14.04 container workaround
|
||||
RUN wget https://storage.googleapis.com/shellcheck/shellcheck-v$SHELLCHECK_VERSION.linux.x86_64.tar.xz -O- | \
|
||||
RUN wget https://github.com/koalaman/shellcheck/releases/download/v$SHELLCHECK_VERSION/shellcheck-v$SHELLCHECK_VERSION.linux.x86_64.tar.xz -O- | \
|
||||
tar xJvf - shellcheck-v$SHELLCHECK_VERSION/shellcheck && \
|
||||
mv shellcheck-v$SHELLCHECK_VERSION/shellcheck /bin && \
|
||||
rmdir shellcheck-v$SHELLCHECK_VERSION && \
|
||||
touch /tmp/libc.so.6 && \
|
||||
echo "alias shellcheck='LD_LIBRARY_PATH=/tmp /bin/shellcheck'" >> /etc/bash.bashrc
|
||||
RUN LD_LIBRARY_PATH=/tmp shellcheck -V
|
||||
rmdir shellcheck-v$SHELLCHECK_VERSION
|
||||
RUN shellcheck -V
|
||||
|
||||
# Set locale
|
||||
RUN locale-gen en_US.UTF-8
|
||||
|
||||
158
README.md
158
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)
|
||||
|
||||
<!-- To update this table of contents, ensure you have run `npm install` then `npm run doctoc` -->
|
||||
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
||||
@@ -24,6 +24,8 @@
|
||||
- [io.js](#iojs)
|
||||
- [System Version of Node](#system-version-of-node)
|
||||
- [Listing Versions](#listing-versions)
|
||||
- [Setting Custom Colors](#setting-custom-colors)
|
||||
- [Persisting custom colors](#persisting-custom-colors)
|
||||
- [Suppressing colorized output](#suppressing-colorized-output)
|
||||
- [.nvmrc](#nvmrc)
|
||||
- [Deeper Shell Integration](#deeper-shell-integration)
|
||||
@@ -31,8 +33,11 @@
|
||||
- [Automatically call `nvm use`](#automatically-call-nvm-use)
|
||||
- [zsh](#zsh)
|
||||
- [Calling `nvm use` automatically in a directory with a `.nvmrc` file](#calling-nvm-use-automatically-in-a-directory-with-a-nvmrc-file)
|
||||
- [fish](#fish)
|
||||
- [Calling `nvm use` automatically in a directory with a `.nvmrc` file](#calling-nvm-use-automatically-in-a-directory-with-a-nvmrc-file-1)
|
||||
- [License](#license)
|
||||
- [Running Tests](#running-tests)
|
||||
- [Environment variables](#environment-variables)
|
||||
- [Bash Completion](#bash-completion)
|
||||
- [Usage](#usage-1)
|
||||
- [Compatibility Issues](#compatibility-issues)
|
||||
@@ -56,10 +61,10 @@ nvm is a version manager for [node.js](https://nodejs.org/en/), designed to be i
|
||||
|
||||
To **install** or **update** nvm, you should run the [install script][2]. To do that, you may either download and run the script manually, or use the following cURL or Wget command:
|
||||
```sh
|
||||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
|
||||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.1/install.sh | bash
|
||||
```
|
||||
```sh
|
||||
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
|
||||
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.1/install.sh | bash
|
||||
```
|
||||
|
||||
Running either of the above commands downloads a script and runs it. The script clones the nvm repository to `~/.nvm`, and attempts to add the source lines from the snippet below to the correct profile file (`~/.bash_profile`, `~/.zshrc`, `~/.profile`, or `~/.bashrc`).
|
||||
@@ -91,9 +96,11 @@ Since OS X 10.9, `/usr/bin/git` has been preset by Xcode command line tools, whi
|
||||
|
||||
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. Create one with `touch ~/.bash_profile` and run the install script again
|
||||
- Since macOS 10.15, the default shell is `zsh` and nvm will look for `.zshrc` to update, none is installed by default. Create one with `touch ~/.zshrc` 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 you use bash, the previous default shell, run `touch ~/.bash_profile` to create the necessary profile file if it does not exist.
|
||||
|
||||
- You might need to restart your terminal instance or run `. ~/.nvm/nvm.sh`. Restarting your terminal/opening a new tab/window, or running the source command will load the command and the new configuration.
|
||||
|
||||
If the above doesn't fix the problem, you may try the following:
|
||||
|
||||
@@ -107,10 +114,10 @@ If the above doesn't fix the problem, you may try the following:
|
||||
|
||||
You can use a task:
|
||||
|
||||
```
|
||||
```yaml
|
||||
- name: nvm
|
||||
shell: >
|
||||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
|
||||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.1/install.sh | bash
|
||||
args:
|
||||
creates: "{{ ansible_env.HOME }}/.nvm/nvm.sh"
|
||||
```
|
||||
@@ -169,7 +176,7 @@ If you have `git` installed (requires git v1.7.10+):
|
||||
|
||||
1. clone this repo in the root of your user profile
|
||||
- `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.35.3`
|
||||
1. `cd ~/.nvm` and check out the latest version with `git checkout v0.37.1`
|
||||
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:
|
||||
@@ -285,6 +292,12 @@ Node has a [schedule](https://github.com/nodejs/Release#release-schedule) for lo
|
||||
|
||||
Any time your local copy of `nvm` connects to https://nodejs.org, it will re-create the appropriate local aliases for all available LTS lines. These aliases (stored under `$NVM_DIR/alias/lts`), are managed by `nvm`, and you should not modify, remove, or create these files - expect your changes to be undone, and expect meddling with these files to cause bugs that will likely not be supported.
|
||||
|
||||
To get the latest LTS version of node and migrate your existing installed packages, use
|
||||
|
||||
```sh
|
||||
nvm install 'lts/*' --reinstall-packages-from=current
|
||||
```
|
||||
|
||||
### Migrating Global Packages While Installing
|
||||
|
||||
If you want to install a new version of Node.js and migrate npm packages from a previous version:
|
||||
@@ -369,12 +382,48 @@ If you want to see what versions are available to install:
|
||||
nvm ls-remote
|
||||
```
|
||||
|
||||
### Setting Custom Colors
|
||||
|
||||
You can set five colors that will be used to display version and alias information. These colors replace the default colors.
|
||||
Initial colors are: g b y r e
|
||||
|
||||
Color codes:
|
||||
|
||||
r/R = red / bold red
|
||||
|
||||
g/G = green / bold green
|
||||
|
||||
b/B = blue / bold blue
|
||||
|
||||
c/C = cyan / bold cyan
|
||||
|
||||
m/M = magenta / bold magenta
|
||||
|
||||
y/Y = yellow / bold yellow
|
||||
|
||||
k/K = black / bold black
|
||||
|
||||
e/W = light grey / white
|
||||
|
||||
```sh
|
||||
nvm set-colors rgBcm
|
||||
```
|
||||
|
||||
#### Persisting custom colors
|
||||
|
||||
If you want the custom colors to persist after terminating the shell, export the NVM_COLORS variable in your shell profile. For example, if you want to use cyan, magenta, green, bold red and bold yellow, add the following line:
|
||||
|
||||
```sh
|
||||
export NVM_COLORS='cmgRY'
|
||||
```
|
||||
|
||||
#### 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`):
|
||||
`nvm help (or -h or --help)`, `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
|
||||
nvm help --no-colors
|
||||
TERM=dumb nvm ls
|
||||
```
|
||||
|
||||
@@ -425,6 +474,8 @@ $ echo "lts/*" > .nvmrc # to default to the latest LTS version
|
||||
$ echo "node" > .nvmrc # to default to the latest version
|
||||
```
|
||||
|
||||
[NB these examples assume a POSIX-compliant shell version of `echo`. If you use a Windows `cmd` development environment, eg the `.nvmrc` file is used to configure a remote Linux deployment, then keep in mind the `"`s will be copied leading to an invalid file. Remove them.]
|
||||
|
||||
Then when you run nvm:
|
||||
|
||||
```sh
|
||||
@@ -450,7 +501,7 @@ If you prefer a lighter-weight solution, the recipes below have been contributed
|
||||
Put the following at the end of your `$HOME/.bashrc`:
|
||||
|
||||
```bash
|
||||
find-up () {
|
||||
find-up() {
|
||||
path=$(pwd)
|
||||
while [[ "$path" != "" && ! -e "$path/$1" ]]; do
|
||||
path=${path%/*}
|
||||
@@ -458,9 +509,9 @@ find-up () {
|
||||
echo "$path"
|
||||
}
|
||||
|
||||
cdnvm(){
|
||||
cdnvm() {
|
||||
cd "$@";
|
||||
nvm_path=$(find-up .nvmrc | tr -d '[:space:]')
|
||||
nvm_path=$(find-up .nvmrc | tr -d '\n')
|
||||
|
||||
# If there are no .nvmrc file, use the default nvm version
|
||||
if [[ ! $nvm_path = *[^[:space:]]* ]]; then
|
||||
@@ -501,6 +552,7 @@ cdnvm(){
|
||||
fi
|
||||
}
|
||||
alias cd='cdnvm'
|
||||
cd $PWD
|
||||
```
|
||||
|
||||
This alias would search 'up' from your current directory in order to detect a `.nvmrc` file. If it finds it, it will switch to that version; if not, it will use the default version.
|
||||
@@ -536,6 +588,45 @@ add-zsh-hook chpwd load-nvmrc
|
||||
load-nvmrc
|
||||
```
|
||||
|
||||
#### fish
|
||||
|
||||
##### Calling `nvm use` automatically in a directory with a `.nvmrc` file
|
||||
This requires that you have [bass](https://github.com/edc/bass) installed.
|
||||
```fish
|
||||
# ~/.config/fish/functions/nvm.fish
|
||||
function nvm
|
||||
bass source ~/.nvm/nvm.sh --no-use ';' nvm $argv
|
||||
end
|
||||
|
||||
# ~/.config/fish/functions/nvm_find_nvmrc.fish
|
||||
function nvm_find_nvmrc
|
||||
bass source ~/.nvm/nvm.sh --no-use ';' nvm_find_nvmrc
|
||||
end
|
||||
|
||||
# ~/.config/fish/functions/load_nvm.fish
|
||||
function load_nvm --on-variable="PWD"
|
||||
set -l default_node_version (nvm version default)
|
||||
set -l node_version (nvm version)
|
||||
set -l nvmrc_path (nvm_find_nvmrc)
|
||||
if test -n "$nvmrc_path"
|
||||
set -l nvmrc_node_version (nvm version (cat $nvmrc_path))
|
||||
if test "$nvmrc_node_version" = "N/A"
|
||||
nvm install (cat $nvmrc_path)
|
||||
else if test nvmrc_node_version != node_version
|
||||
nvm use $nvmrc_node_version
|
||||
end
|
||||
else if test "$node_version" != "$default_node_version"
|
||||
echo "Reverting to default Node version"
|
||||
nvm use default
|
||||
end
|
||||
end
|
||||
|
||||
# ~/.config/fish/config.fish
|
||||
# You must call it on initialization or listening to directory switching won't work
|
||||
load_nvm
|
||||
```
|
||||
|
||||
|
||||
## License
|
||||
|
||||
nvm is released under the MIT license.
|
||||
@@ -572,6 +663,19 @@ Run all of the tests like this:
|
||||
|
||||
Nota bene: Avoid running nvm while the tests are running.
|
||||
|
||||
## Environment variables
|
||||
|
||||
nvm exposes the following environment variables:
|
||||
|
||||
- `NVM_DIR` - nvm's installation directory.
|
||||
- `NVM_BIN` - where node, npm, and global packages for the active version of node are installed.
|
||||
- `NVM_INC` - node's include file directory (useful for building C/C++ addons for node).
|
||||
- `NVM_CD_FLAGS` - used to maintain compatibility with zsh.
|
||||
- `NVM_RC_VERSION` - version from .nvmrc file if being used.
|
||||
|
||||
Additionally, nvm modifies `PATH`, and, if present, `MANPATH` and `NODE_PATH` when changing versions.
|
||||
|
||||
|
||||
## Bash Completion
|
||||
|
||||
To activate, you need to source `bash_completion`:
|
||||
@@ -588,36 +692,36 @@ nvm:
|
||||
> $ nvm <kbd>Tab</kbd>
|
||||
|
||||
```
|
||||
alias deactivate install ls run unload
|
||||
clear-cache exec list ls-remote unalias use
|
||||
current help list-remote reinstall-packages uninstall version
|
||||
alias deactivate install list-remote reinstall-packages uninstall version
|
||||
cache exec install-latest-npm ls run unload version-remote
|
||||
current help list ls-remote unalias use which
|
||||
```
|
||||
|
||||
nvm alias:
|
||||
> $ nvm alias <kbd>Tab</kbd>
|
||||
|
||||
```
|
||||
default
|
||||
default iojs lts/* lts/argon lts/boron lts/carbon lts/dubnium lts/erbium node stable unstable
|
||||
```
|
||||
|
||||
> $ nvm alias my_alias <kbd>Tab</kbd>
|
||||
|
||||
```
|
||||
v0.6.21 v0.8.26 v0.10.28
|
||||
v10.22.0 v12.18.3 v14.8.0
|
||||
```
|
||||
|
||||
nvm use:
|
||||
> $ nvm use <kbd>Tab</kbd>
|
||||
|
||||
```
|
||||
my_alias default v0.6.21 v0.8.26 v0.10.28
|
||||
my_alias default v10.22.0 v12.18.3 v14.8.0
|
||||
```
|
||||
|
||||
nvm uninstall:
|
||||
> $ nvm uninstall <kbd>Tab</kbd>
|
||||
|
||||
```
|
||||
my_alias default v0.6.21 v0.8.26 v0.10.28
|
||||
my_alias default v10.22.0 v12.18.3 v14.8.0
|
||||
```
|
||||
|
||||
## Compatibility Issues
|
||||
@@ -656,7 +760,7 @@ If installing nvm on Alpine Linux *is* still what you want or need to do, you sh
|
||||
|
||||
```sh
|
||||
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/nvm-sh/nvm/v0.35.3/install.sh | bash
|
||||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.1/install.sh | bash
|
||||
```
|
||||
|
||||
The Node project has some desire but no concrete plans (due to the overheads of building, testing and support) to offer Alpine-compatible binaries.
|
||||
@@ -742,9 +846,19 @@ sudo chmod ugo-x /usr/libexec/path_helper
|
||||
|
||||
More on this issue in [dotphiles/dotzsh](https://github.com/dotphiles/dotzsh#mac-os-x).
|
||||
|
||||
**nvm is not compatible with the npm config "prefix" option**
|
||||
|
||||
Some solutions for this issue can be found [here](https://github.com/nvm-sh/nvm/issues/1245)
|
||||
|
||||
There is one more edge case causing this issue, and that's a **mismatch between the `$HOME` path and the user's home directory's actual name**.
|
||||
|
||||
You have to make sure that the user directory name in `$HOME` and the user directory name you'd see from running `ls /Users/` **are capitalized the same way** ([See this issue](https://github.com/nvm-sh/nvm/issues/2261)).
|
||||
|
||||
To change the user directory and/or account name follow the instructions [here](https://support.apple.com/en-us/HT201548)
|
||||
|
||||
[1]: https://github.com/nvm-sh/nvm.git
|
||||
[2]: https://github.com/nvm-sh/nvm/blob/v0.35.3/install.sh
|
||||
[2]: https://github.com/nvm-sh/nvm/blob/v0.37.1/install.sh
|
||||
[3]: https://travis-ci.org/nvm-sh/nvm
|
||||
[4]: https://github.com/nvm-sh/nvm/releases/tag/v0.35.3
|
||||
[4]: https://github.com/nvm-sh/nvm/releases/tag/v0.37.1
|
||||
[Urchin]: https://github.com/scraperwiki/urchin
|
||||
[Fish]: http://fishshell.com
|
||||
|
||||
@@ -19,7 +19,7 @@ nvm_install_dir() {
|
||||
}
|
||||
|
||||
nvm_latest_version() {
|
||||
echo "v0.35.3"
|
||||
echo "v0.37.1"
|
||||
}
|
||||
|
||||
nvm_profile_is_bash_or_zsh() {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "nvm",
|
||||
"version": "0.35.3",
|
||||
"version": "0.37.1",
|
||||
"description": "Node Version Manager - Simple bash script to manage multiple active node.js versions",
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make test-$shell",
|
||||
"test/fast": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=fast test-$shell",
|
||||
"test/fast": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); env -i TERM=\"$TERM\" bash -lc \"make TEST_SUITE=fast test-$shell\"",
|
||||
"test/slow": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=slow test-$shell",
|
||||
"test/install_script": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=install_script test-$shell",
|
||||
"test/installation": "npm run --silent test/installation/node && npm run --silent test/installation/iojs",
|
||||
@@ -37,10 +37,10 @@
|
||||
"homepage": "https://github.com/nvm-sh/nvm",
|
||||
"devDependencies": {
|
||||
"dockerfile_lint": "^0.3.2",
|
||||
"doctoc": "^1.2.0",
|
||||
"eclint": "^2.6.0",
|
||||
"replace": "^0.3.0",
|
||||
"semver": "^5.0.1",
|
||||
"urchin": "^0.0.5",
|
||||
"doctoc": "^1.2.0"
|
||||
"urchin": "^0.0.5"
|
||||
}
|
||||
}
|
||||
|
||||
25
test/fast/Aliases/nvm_list_aliases calls nvm_get_colors
Executable file
25
test/fast/Aliases/nvm_list_aliases calls nvm_get_colors
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
die () {
|
||||
echo "nvm_list_aliases did not call nvm_get_colors. Expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"
|
||||
exit 1
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
nvm_get_colors(){
|
||||
echo "0;95m"
|
||||
}
|
||||
|
||||
nvm_alias_path() {
|
||||
nvm_echo "../../../alias"
|
||||
}
|
||||
|
||||
OUTPUT=$(command printf %b $(nvm_list_aliases test-stable-1) | awk '{ print substr($0, 1, 19); }')
|
||||
|
||||
EXPECTED_OUTPUT=$(command printf %b "\033[0;95mtest-stable-1" | awk '{ print substr($0, 1, 19); }')
|
||||
echo "\033[0m"
|
||||
|
||||
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die
|
||||
28
test/fast/Aliases/nvm_print_alias_path calls nvm_get_colors
Executable file
28
test/fast/Aliases/nvm_print_alias_path calls nvm_get_colors
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
die () {
|
||||
# echo "$@" ;
|
||||
echo "Expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"
|
||||
exit 1
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
nvm_get_colors(){
|
||||
echo "0;95m"
|
||||
}
|
||||
|
||||
# nvm_print_alias_path call nvm_print_formatted_alias which calls nvm_get-colors
|
||||
# the output of nvm_print_alias_path uses the color code returned by nvm_get_colors (redefined above)
|
||||
NVM_ALIAS_DIR='../../../alias'
|
||||
|
||||
OUTPUT=$(command printf %b $(nvm_print_alias_path "$NVM_ALIAS_DIR" "$NVM_ALIAS_DIR"/test-stable-1) | awk '{ print substr($0, 1, 24); }')
|
||||
|
||||
EXPECTED_OUTPUT=$(command printf %b "\033[0;95mtest-stable-1\033[0m")
|
||||
|
||||
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die
|
||||
|
||||
|
||||
set +e
|
||||
21
test/fast/Aliases/nvm_print_formatted_alias calls nvm_get_colors
Executable file
21
test/fast/Aliases/nvm_print_formatted_alias calls nvm_get_colors
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
die () {
|
||||
echo "Expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"
|
||||
exit 1
|
||||
}
|
||||
|
||||
set -e
|
||||
# # # expecting in red and two grays:
|
||||
OUTPUT=$(echo $(nvm_print_formatted_alias fakealias fakedest) | awk '{ print substr($0, 1, 21); }')
|
||||
EXPECTED_OUTPUT="$(command printf %b "\033[0;31mfakealias\033[0m ")"
|
||||
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die
|
||||
|
||||
# expecting in bold yellow and two grays:
|
||||
nvm set-colors bbbYb
|
||||
OUTPUT=$(echo $(nvm_print_formatted_alias fakealias fakedest) | awk '{ print substr($0, 1, 21); }')
|
||||
EXPECTED_OUTPUT="$(command printf %b "\033[1;33mfakealias\033[0m ")"
|
||||
|
||||
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die
|
||||
40
test/fast/Listing versions/Running "nvm ls" should not show a trailing slash
Executable file
40
test/fast/Listing versions/Running "nvm ls" should not show a trailing slash
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/bin/zsh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
\. ../../common.sh
|
||||
|
||||
if type setopt >/dev/null 2>&1; then setopt local_options markdirs; fi
|
||||
|
||||
die () {
|
||||
if type unsetopt >/dev/null 2>&1; then unsetopt local_options markdirs; fi
|
||||
echo "$@";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
make_fake_node v0.0.1
|
||||
make_fake_node v0.0.3
|
||||
make_fake_node v0.0.9
|
||||
make_fake_node v0.3.1
|
||||
make_fake_node v0.3.3
|
||||
make_fake_node v0.3.9
|
||||
make_fake_node v0.12.87
|
||||
make_fake_node v0.12.9
|
||||
make_fake_iojs v0.1.2
|
||||
make_fake_iojs v0.10.2
|
||||
|
||||
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}<"
|
||||
@@ -5,7 +5,7 @@ set -ex
|
||||
BEFORE="./before.tmp"
|
||||
AFTER="./after.tmp"
|
||||
|
||||
cleanup () { echo rm -f "${BEFORE}" "${AFTER}"; }
|
||||
cleanup () { rm -f "${BEFORE}" "${AFTER}"; }
|
||||
die () { echo "$@" ; cleanup ; exit 1; }
|
||||
|
||||
typeset -f | awk '/ \(\) $/ && !/^main / {print $1}' > "${BEFORE}"
|
||||
|
||||
@@ -27,7 +27,9 @@ EXPECTED_OUTPUT="$(nvm_add_iojs_prefix ${VERSION})"
|
||||
|
||||
nvm use --delete-prefix iojs || die '`nvm use iojs` failed'
|
||||
|
||||
CURRENT="$(nvm current)"
|
||||
# Remove node_modules/.bin from the path so that the system version `which` is
|
||||
# used in nvm_ls_current
|
||||
PATH=$(echo "$PATH" | tr ":" "\n" | grep -v "node_modules/.bin" | tr "\n" ":") CURRENT="$(nvm current)"
|
||||
echo "current: ${CURRENT}"
|
||||
|
||||
[ "${CURRENT}" = "${IOJS_VERSION}" ] || die "expected >${IOJS_VERSION}<; got >${CURRENT}<"
|
||||
|
||||
21
test/fast/Set Colors/nvm_echo_with_colors
Executable file
21
test/fast/Set Colors/nvm_echo_with_colors
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
die () {
|
||||
echo "Expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"
|
||||
exit 1
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
echo "Tested nvm_echo_with_colors"
|
||||
}
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
OUTPUT="$(nvm_echo_with_colors "\033[0;36mCyan-colored text")"
|
||||
EXPECTED_OUTPUT=$(printf "\033[0;36mCyan-colored text")
|
||||
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die
|
||||
|
||||
cleanup
|
||||
19
test/fast/Set Colors/nvm_err_with_colors
Executable file
19
test/fast/Set Colors/nvm_err_with_colors
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
die () { echo "$@" ; cleanup ; exit 1; }
|
||||
|
||||
cleanup() {
|
||||
echo "Tested nvm_err_with_colors"
|
||||
}
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
set +ex
|
||||
OUTPUT="$(nvm_err_with_colors "\033[0;35mMagenta-colored text" 2>&1)"
|
||||
set -ex
|
||||
EXPECTED_OUTPUT=$(printf "\033[0;35mMagenta-colored text")
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die
|
||||
|
||||
cleanup
|
||||
24
test/fast/Set Colors/nvm_print_default_alias calls nvm_get_colors
Executable file
24
test/fast/Set Colors/nvm_print_default_alias calls nvm_get_colors
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
die () {
|
||||
# echo "$@" ;
|
||||
echo "Expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"
|
||||
exit 1
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
nvm_get_colors(){
|
||||
echo "0;95m"
|
||||
}
|
||||
|
||||
# nvm_print_default_alias call nvm_print_formatted_alias which calls nvm_get-colors
|
||||
# the output of nvm_print_default_alias uses the color code returned by nvm_get_colors (redefined above)
|
||||
OUTPUT=$(command printf %b $(nvm_print_default_alias node ./alias v14.7.0) | awk '{ print substr($0, 1, 11); }')
|
||||
EXPECTED_OUTPUT=$(command printf %b "\033[0;95mnode")
|
||||
|
||||
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die
|
||||
|
||||
set +e
|
||||
52
test/fast/Set Colors/nvm_print_versions calls nvm_get_colors
Executable file
52
test/fast/Set Colors/nvm_print_versions calls nvm_get_colors
Executable file
@@ -0,0 +1,52 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
set -e
|
||||
|
||||
die () {
|
||||
# echo "$@" ;
|
||||
echo "Expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"
|
||||
exit 1
|
||||
}
|
||||
cleanup() {
|
||||
if [ -n TEMP_NVM_COLORS ]; then
|
||||
export NVM_COLORS=TEMP_NVM_COLORS
|
||||
fi
|
||||
unset TEMP_NVM_COLORS
|
||||
}
|
||||
|
||||
if [ -n ${NVM_COLORS} ]; then
|
||||
export TEMP_NVM_COLORS=NVM_COLORS
|
||||
unset NVM_COLORS
|
||||
fi
|
||||
|
||||
# default system color
|
||||
nvm use system
|
||||
OUTPUT=$(nvm_print_versions system)
|
||||
FORMAT="\033[0;32m-> %12s\033[0m"
|
||||
VERSION='system'
|
||||
EXPECTED_OUTPUT=$(command printf -- "${FORMAT}\\n" "${VERSION}")
|
||||
|
||||
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die
|
||||
|
||||
nvm_ls_current() { echo "current";}
|
||||
|
||||
# default current color
|
||||
OUTPUT=$(nvm_print_versions current)
|
||||
FORMAT="\033[0;32m-> %12s\033[0m"
|
||||
VERSION="current"
|
||||
EXPECTED_OUTPUT=$(command printf -- "${FORMAT}\\n" "${VERSION}")
|
||||
|
||||
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die
|
||||
|
||||
# custom current color
|
||||
nvm set-colors YCMGR
|
||||
OUTPUT=$(nvm_print_versions current)
|
||||
FORMAT="\033[1;35m-> %12s\033[0m"
|
||||
VERSION="current"
|
||||
EXPECTED_OUTPUT=$(command printf -- "${FORMAT}\\n" "${VERSION}")
|
||||
|
||||
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die
|
||||
|
||||
cleanup
|
||||
@@ -1,17 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
\. ../../../nvm.sh
|
||||
\. ../../common.sh
|
||||
|
||||
assert_not_ok iojs_version_has_solaris_binary ""
|
||||
assert_not_ok iojs_version_has_solaris_binary "foo"
|
||||
assert_not_ok iojs_version_has_solaris_binary "v1.1.0"
|
||||
|
||||
assert_ok iojs_version_has_solaris_binary "v3.3.1"
|
||||
assert_ok iojs_version_has_solaris_binary "iojs-v3.3.1"
|
||||
assert_ok iojs_version_has_solaris_binary "v3.3.2"
|
||||
assert_ok iojs_version_has_solaris_binary "iojs-v3.3.2"
|
||||
assert_ok iojs_version_has_solaris_binary "v3.4.1"
|
||||
assert_ok iojs_version_has_solaris_binary "iojs-v3.4.1"
|
||||
0
test/fast/Unit tests/mocks/project_dirs/inside-n_m-nested-pkg/node_modules/foo/bar/.gitkeep
generated
vendored
Normal file
0
test/fast/Unit tests/mocks/project_dirs/inside-n_m-nested-pkg/node_modules/foo/bar/.gitkeep
generated
vendored
Normal file
0
test/fast/Unit tests/mocks/project_dirs/inside-n_m-nested-pkg/node_modules/foo/package.json
generated
vendored
Normal file
0
test/fast/Unit tests/mocks/project_dirs/inside-n_m-nested-pkg/node_modules/foo/package.json
generated
vendored
Normal file
0
test/fast/Unit tests/mocks/project_dirs/inside-n_m-nested/node_modules/foo/bar/.gitkeep
generated
vendored
Normal file
0
test/fast/Unit tests/mocks/project_dirs/inside-n_m-nested/node_modules/foo/bar/.gitkeep
generated
vendored
Normal file
0
test/fast/Unit tests/mocks/project_dirs/nested-both/node_modules/.gitkeep
generated
vendored
Normal file
0
test/fast/Unit tests/mocks/project_dirs/nested-both/node_modules/.gitkeep
generated
vendored
Normal file
0
test/fast/Unit tests/mocks/project_dirs/nested-n_m/node_modules/.gitkeep
generated
vendored
Normal file
0
test/fast/Unit tests/mocks/project_dirs/nested-n_m/node_modules/.gitkeep
generated
vendored
Normal file
0
test/fast/Unit tests/mocks/project_dirs/no-nesting-both/node_modules/.gitkeep
generated
vendored
Normal file
0
test/fast/Unit tests/mocks/project_dirs/no-nesting-both/node_modules/.gitkeep
generated
vendored
Normal file
0
test/fast/Unit tests/mocks/project_dirs/no-nesting-n_m/node_modules/.gitkeep
generated
vendored
Normal file
0
test/fast/Unit tests/mocks/project_dirs/no-nesting-n_m/node_modules/.gitkeep
generated
vendored
Normal file
@@ -1,33 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
\. ../../../nvm.sh
|
||||
\. ../../common.sh
|
||||
|
||||
# Invalid version numbers fail
|
||||
assert_not_ok node_version_has_solaris_binary ""
|
||||
assert_not_ok node_version_has_solaris_binary "foo"
|
||||
|
||||
# "Invalid" node version numbers fail
|
||||
assert_not_ok node_version_has_solaris_binary "v1.0.0"
|
||||
assert_not_ok node_version_has_solaris_binary "v3.3.1"
|
||||
|
||||
# Valid io.js version numbers that have a Solaris binary fail
|
||||
assert_not_ok node_version_has_solaris_binary "iojs-v3.3.1"
|
||||
|
||||
# Invalid io.js version numbers fail
|
||||
assert_not_ok node_version_has_solaris_binary "iojs-v0.12.7"
|
||||
|
||||
# Valid node version numbers that don't have a Solaris binary fail
|
||||
assert_not_ok node_version_has_solaris_binary "v0.8.5"
|
||||
|
||||
# Valid node version numbers that have a Solaris binary succeed
|
||||
assert_ok node_version_has_solaris_binary "v0.8.6"
|
||||
assert_ok node_version_has_solaris_binary "v0.10.0"
|
||||
assert_ok node_version_has_solaris_binary "v0.12.7"
|
||||
|
||||
# Valid "merged" version numbers fail, because they're not
|
||||
# considered node version numbers
|
||||
assert_not_ok node_version_has_solaris_binary "v4.0.0"
|
||||
assert_not_ok node_version_has_solaris_binary "v4.1.1"
|
||||
@@ -6,9 +6,17 @@ die () { echo "$@" ; cleanup ; exit 1; }
|
||||
|
||||
cleanup() {
|
||||
unset -f nvm_download nvm_ls_remote nvm_ls_remote_iojs
|
||||
if [ -n TEMP_NVM_COLORS ]; then
|
||||
export NVM_COLORS=TEMP_NVM_COLORS
|
||||
fi
|
||||
unset TEMP_NVM_COLORS
|
||||
}
|
||||
|
||||
\. ../../../nvm.sh
|
||||
if [ -n ${NVM_COLORS} ]; then
|
||||
export TEMP_NVM_COLORS=NVM_COLORS
|
||||
unset NVM_COLORS
|
||||
fi
|
||||
|
||||
nvm deactivate 2>/dev/null || die 'unable to deactivate'
|
||||
|
||||
|
||||
52
test/fast/Unit tests/nvm set_colors
Executable file
52
test/fast/Unit tests/nvm set_colors
Executable file
@@ -0,0 +1,52 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
die () { echo "$@" ; cleanup ; exit 1; }
|
||||
|
||||
cleanup() {
|
||||
unset NVM_COLORS
|
||||
unset -f nvm_has_colors
|
||||
if [ -n TEMP_NVM_COLORS ]; then
|
||||
export NVM_COLORS=TEMP_NVM_COLORS
|
||||
fi
|
||||
unset TEMP_NVM_COLORS
|
||||
}
|
||||
|
||||
\. ../../../nvm.sh
|
||||
# NVM_COLORS is not set
|
||||
if [ -n ${NVM_COLORS} ]; then
|
||||
export TEMP_NVM_COLORS=NVM_COLORS
|
||||
unset NVM_COLORS
|
||||
fi
|
||||
|
||||
# test valid setting colors/
|
||||
nvm set-colors rgbyc
|
||||
OUTPUT="${NVM_COLORS}"
|
||||
EXPECTED_OUTPUT="rgbyc"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "NVM_SET_COLORS failed with valid input; got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<"
|
||||
|
||||
# test invalid 4 colors
|
||||
set +ex
|
||||
OUTPUT="$(echo $(nvm set-colors rgby 2>&1) | awk '{ print substr($0, length($0)-92, 93); }')"
|
||||
EXPECTED_OUTPUT="$(command printf %b "\033[1;37mPlease pass in five \033[1;31mvalid color codes\033[1;37m. Choose from: rRgGbBcCyYmMkKeW\033[0m")"
|
||||
set -ex
|
||||
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "NVM_SET_COLORS did not fail with invalid input; got >${OUTPUT}, < expected >${EXPECTED_OUTPUT}<"
|
||||
|
||||
# test invalid color codes
|
||||
set +ex
|
||||
OUTPUT="$(echo $(nvm set-colors p3gq7 2>&1) | awk '{ print substr($0, length($0)-92, 93); }')"
|
||||
EXPECTED_OUTPUT="$(command printf %b "\033[1;37mPlease pass in five \033[1;31mvalid color codes\033[1;37m. Choose from: rRgGbBcCyYmMkKeW\033[0m")"
|
||||
set -ex
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "NVM_SET_COLORS did not fail with invalid input; got >${OUTPUT}<, expected >${EXPECTED_OUTPUT}<"
|
||||
|
||||
#test system does not support at least 8 colors
|
||||
nvm_has_colors() { return 1; }
|
||||
set +ex
|
||||
OUTPUT="$(echo $(nvm set-colors mcyGb 2>&1) | awk '{ print substr($0, length($0)-76, 77); }')"
|
||||
set -ex
|
||||
EXPECTED_OUTPUT="WARNING: Colors may not display because they are not supported in this shell."
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "NVM_SET_COLORS did not recognize lack of color support; got >${OUTPUT}<, expected >${EXPECTED_OUTPUT}<"
|
||||
|
||||
cleanup
|
||||
9
test/fast/Unit tests/nvm_check_for_help
Executable file
9
test/fast/Unit tests/nvm_check_for_help
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
TERM=dumb nvm clear-cache --help | grep 'Usage:' || die 'did not print help menu'
|
||||
TERM=dumb nvm cache help version | grep 'Usage:' || die 'did not print help menu'
|
||||
TERM=dumb nvm cache -h version| grep 'Usage:' || die 'did not print help menu'
|
||||
@@ -1,18 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
cleanup () {
|
||||
rm tmp/emptyfile tmp/testfile
|
||||
rmdir tmp
|
||||
}
|
||||
die () { echo "$@" ; cleanup; exit 1; }
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
mkdir -p tmp
|
||||
touch tmp/emptyfile
|
||||
echo -n "test" > tmp/testfile
|
||||
|
||||
nvm_checksum tmp/emptyfile "da39a3ee5e6b4b0d3255bfef95601890afd80709" || die "nvm_checksum on an empty file did not match the SHA1 digest of the empty string"
|
||||
nvm_checksum tmp/testfile "da39a3ee5e6b4b0d3255bfef95601890afd80709" && die "nvm_checksum allowed a bad checksum"
|
||||
|
||||
cleanup
|
||||
@@ -1,13 +1,26 @@
|
||||
#!/bin/sh
|
||||
|
||||
TEST_PWD=$(pwd)
|
||||
TEST_DIR="$TEST_PWD/nvm_die_on_prefix_tmp"
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
TEST_VERSION_DIR="${TEST_DIR}/version"
|
||||
|
||||
cleanup () {
|
||||
rm -rf "$TEST_DIR"
|
||||
alias nvm_has='\nvm_has'
|
||||
alias npm='\npm'
|
||||
unset -f nvm_has npm
|
||||
}
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
\. ../../../nvm.sh
|
||||
die () {
|
||||
echo "$@";
|
||||
cleanup;
|
||||
exit 1;
|
||||
}
|
||||
|
||||
[ ! -e "$TEST_DIR" ] && mkdir "$TEST_DIR"
|
||||
|
||||
OUTPUT="$(nvm_die_on_prefix 2>&1)"
|
||||
EXPECTED_OUTPUT="First argument \"delete the prefix\" must be zero or one"
|
||||
@@ -22,60 +35,158 @@ EXIT_CODE="$(nvm_die_on_prefix 2 >/dev/null 2>&1; echo $?)"
|
||||
[ "_$EXIT_CODE" = "_1" ] || die "'nvm_die_on_prefix' did not exit with 1; got "$EXIT_CODE""
|
||||
|
||||
OUTPUT="$(nvm_die_on_prefix 0 2>&1)"
|
||||
EXPECTED_OUTPUT="Second argument \"nvm command\" must be nonempty"
|
||||
EXPECTED_OUTPUT='Second argument "nvm command", and third argument "nvm version dir", must both be nonempty'
|
||||
EXIT_CODE="$(nvm_die_on_prefix 0 >/dev/null 2>&1; echo $?)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_die_on_prefix 0' did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||
[ "_$EXIT_CODE" = "_2" ] || die "'nvm_die_on_prefix 0' did not exit with 2; got '$EXIT_CODE'"
|
||||
|
||||
nvm_has() { return 1; } # ie, npm is not installed
|
||||
OUTPUT="$(nvm_die_on_prefix 0 foo 2>&1)"
|
||||
OUTPUT="$(nvm_die_on_prefix 0 version_dir foo 2>&1)"
|
||||
[ -z "$OUTPUT" ] || die "nvm_die_on_prefix was not a noop when nvm_has returns 1, got '$OUTPUT'"
|
||||
|
||||
nvm_has() { return 0; }
|
||||
|
||||
OUTPUT="$(nvm_die_on_prefix 0 foo "$(nvm_version_dir new)" 2>&1)"
|
||||
[ -z "$OUTPUT" ] || die "'nvm_die_on_prefix' was not a noop when prefix is good; got '$OUTPUT'"
|
||||
|
||||
mkdir -p "$(nvm_version_dir new)"
|
||||
ln -s "$(nvm_version_dir new)" "$TEST_DIR/node"
|
||||
|
||||
npm() {
|
||||
local args
|
||||
args="$@"
|
||||
if [ "_$args" = "_config --loglevel=warn get prefix" ]; then
|
||||
echo "$(nvm_version_dir new)/good prefix"
|
||||
echo "$TEST_DIR/node"
|
||||
fi
|
||||
}
|
||||
OUTPUT="$(nvm_die_on_prefix 0 foo 2>&1)"
|
||||
[ -z "$OUTPUT" ] || die "'nvm_die_on_prefix' was not a noop when prefix is good; got '$OUTPUT'"
|
||||
|
||||
OUTPUT="$(PREFIX=bar nvm_die_on_prefix 0 foo 2>&1)"
|
||||
OUTPUT="$(nvm_die_on_prefix 0 foo "$(nvm_version_dir new)" 2>&1)"
|
||||
[ -z "$OUTPUT" ] || die "'nvm_die_on_prefix' was not a noop when directory is equivalent; got '$OUTPUT'"
|
||||
|
||||
OUTPUT="$(PREFIX=bar nvm_die_on_prefix 0 foo "$(nvm_version_dir new)" 2>&1)"
|
||||
EXPECTED_OUTPUT='nvm is not compatible with the "PREFIX" environment variable: currently set to "bar"
|
||||
Run `unset PREFIX` to unset it.'
|
||||
EXIT_CODE="$(export PREFIX=bar ; nvm_die_on_prefix 0 foo >/dev/null 2>&1; echo $?)"
|
||||
EXIT_CODE="$(export PREFIX=bar ; nvm_die_on_prefix 0 foo "$(nvm_version_dir new)" >/dev/null 2>&1; echo $?)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'PREFIX=bar nvm_die_on_prefix 0 foo' did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||
[ "_$EXIT_CODE" = "_3" ] || die "'PREFIX=bar nvm_die_on_prefix 0 foo' did not exit with 3; got '$EXIT_CODE'"
|
||||
|
||||
OUTPUT="$(export NPM_CONFIG_PREFIX=bar ; nvm_die_on_prefix 0 foo 2>&1)"
|
||||
OUTPUT="$(export NPM_CONFIG_PREFIX=bar ; nvm_die_on_prefix 0 foo "$(nvm_version_dir new)" 2>&1)"
|
||||
EXPECTED_OUTPUT='nvm is not compatible with the "NPM_CONFIG_PREFIX" environment variable: currently set to "bar"
|
||||
Run `unset NPM_CONFIG_PREFIX` to unset it.'
|
||||
EXIT_CODE="$(export NPM_CONFIG_PREFIX=bar ; nvm_die_on_prefix 0 foo >/dev/null 2>&1; echo $?)"
|
||||
EXIT_CODE="$(export NPM_CONFIG_PREFIX=bar ; nvm_die_on_prefix 0 foo "$(nvm_version_dir new)" >/dev/null 2>&1; echo $?)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'NPM_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo' did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||
[ "_$EXIT_CODE" = "_4" ] || die "'NPM_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo' did not exit with 4; got '$EXIT_CODE'"
|
||||
|
||||
OUTPUT="$(export npm_CONFIG_PREFIX=bar ; nvm_die_on_prefix 0 foo 2>&1)"
|
||||
OUTPUT="$(export npm_CONFIG_PREFIX=bar ; nvm_die_on_prefix 0 foo "$(nvm_version_dir new)" 2>&1)"
|
||||
EXPECTED_OUTPUT='nvm is not compatible with the "npm_CONFIG_PREFIX" environment variable: currently set to "bar"
|
||||
Run `unset npm_CONFIG_PREFIX` to unset it.'
|
||||
EXIT_CODE="$(export npm_CONFIG_PREFIX=bar ; nvm_die_on_prefix 0 foo >/dev/null 2>&1; echo $?)"
|
||||
EXIT_CODE="$(export npm_CONFIG_PREFIX=bar ; nvm_die_on_prefix 0 foo "$(nvm_version_dir new)" >/dev/null 2>&1; echo $?)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'npm_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo' did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||
[ "_$EXIT_CODE" = "_4" ] || die "'npm_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo' did not exit with 4; got '$EXIT_CODE'"
|
||||
|
||||
npm() {
|
||||
local args
|
||||
args="$@"
|
||||
if [ "_$args" = "_config --loglevel=warn get prefix" ]; then
|
||||
echo "./bad prefix"
|
||||
fi
|
||||
}
|
||||
OUTPUT="$(nvm_die_on_prefix 0 foo 2>&1)"
|
||||
EXPECTED_OUTPUT="nvm is not compatible with the npm config \"prefix\" option: currently set to \"./bad prefix\"
|
||||
Run \`npm config delete prefix\` or \`foo\` to unset it."
|
||||
EXIT_CODE="$(nvm_die_on_prefix 0 foo >/dev/null 2>&1; echo $?)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_die_on_prefix 0 foo' did not error with '$EXPECTED_OUTPUT' with bad prefix set; got '$OUTPUT'"
|
||||
[ "_$EXIT_CODE" = "_10" ] || die "'nvm_die_on_prefix 0 foo' did not exit with 10 with bad prefix set; got '$EXIT_CODE'"
|
||||
OUTPUT="$(export FOO='NPM_CONFIG_PREFIX' ; nvm_die_on_prefix 0 foo "$(nvm_version_dir new)" 2>&1)"
|
||||
[ -z "$OUTPUT" ] || die "'nvm_die_on_prefix' was not a noop; got '$OUTPUT'"
|
||||
|
||||
# npmrc tests
|
||||
(
|
||||
cd "${TEST_DIR}"
|
||||
touch package.json
|
||||
|
||||
# project: prefix
|
||||
echo 'prefix=garbage' > .npmrc
|
||||
OUTPUT="$(nvm_die_on_prefix 0 foo "${TEST_VERSION_DIR}" 2>&1)"
|
||||
EXPECTED_OUTPUT="Your project npmrc file ($(nvm_sanitize_path "${TEST_DIR}")/.npmrc)
|
||||
has a \`globalconfig\` and/or a \`prefix\` setting, which are incompatible with nvm.
|
||||
Run \`foo\` to unset it."
|
||||
EXIT_CODE="$(nvm_die_on_prefix 0 foo "${TEST_VERSION_DIR}" >/dev/null 2>&1; echo $?)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_die_on_prefix 0 foo' with project .npmrc that has prefix did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||
[ "_$EXIT_CODE" = "_10" ] || die "'nvm_die_on_prefix 0 foo' with project .npmrc that has prefix did not exit with 10; got '$EXIT_CODE'"
|
||||
|
||||
# project: globalconfig
|
||||
echo 'globalconfig=garbage' > .npmrc
|
||||
OUTPUT="$(nvm_die_on_prefix 0 foo "${TEST_VERSION_DIR}" 2>&1)"
|
||||
EXPECTED_OUTPUT="Your project npmrc file ($(nvm_sanitize_path "${TEST_DIR}")/.npmrc)
|
||||
has a \`globalconfig\` and/or a \`prefix\` setting, which are incompatible with nvm.
|
||||
Run \`foo\` to unset it."
|
||||
EXIT_CODE="$(nvm_die_on_prefix 0 foo "${TEST_VERSION_DIR}" >/dev/null 2>&1; echo $?)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_die_on_prefix 0 foo' with project .npmrc that has globalconfig did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||
[ "_$EXIT_CODE" = "_10" ] || die "'nvm_die_on_prefix 0 foo' with project .npmrc that has globalconfig did not exit with 10; got '$EXIT_CODE'"
|
||||
|
||||
rm "${TEST_DIR}/.npmrc" || die '.npmrc could not be removed'
|
||||
|
||||
mkdir -p "${TEST_VERSION_DIR}"
|
||||
GLOBAL_NPMRC="${TEST_VERSION_DIR}/etc/npmrc"
|
||||
mkdir -p "${TEST_VERSION_DIR}/etc"
|
||||
|
||||
BUILTIN_NPMRC="${TEST_VERSION_DIR}/lib/node_modules/npm/npmrc"
|
||||
mkdir -p "${TEST_VERSION_DIR}/lib/node_modules/npm/"
|
||||
|
||||
export HOME="${TEST_VERSION_DIR}"
|
||||
USER_NPMRC="${TEST_VERSION_DIR}/.npmrc"
|
||||
|
||||
# global: prefix
|
||||
echo 'prefix=garbage' > "${GLOBAL_NPMRC}"
|
||||
OUTPUT="$(nvm_die_on_prefix 0 foo "${TEST_VERSION_DIR}" 2>&1)"
|
||||
EXPECTED_OUTPUT="Your global npmrc file ($(nvm_sanitize_path "${GLOBAL_NPMRC}"))
|
||||
has a \`globalconfig\` and/or a \`prefix\` setting, which are incompatible with nvm.
|
||||
Run \`foo\` to unset it."
|
||||
EXIT_CODE="$(nvm_die_on_prefix 0 foo "${TEST_VERSION_DIR}" >/dev/null 2>&1; echo $?)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_die_on_prefix 0 foo' with global npmrc that has prefix did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||
[ "_$EXIT_CODE" = "_10" ] || die "'nvm_die_on_prefix 0 foo' with global npmrc that has prefix did not exit with 10; got '$EXIT_CODE'"
|
||||
|
||||
# global: globalconfig
|
||||
echo 'globalconfig=garbage' > "${GLOBAL_NPMRC}"
|
||||
OUTPUT="$(nvm_die_on_prefix 0 foo "${TEST_VERSION_DIR}" 2>&1)"
|
||||
EXPECTED_OUTPUT="Your global npmrc file ($(nvm_sanitize_path "${GLOBAL_NPMRC}"))
|
||||
has a \`globalconfig\` and/or a \`prefix\` setting, which are incompatible with nvm.
|
||||
Run \`foo\` to unset it."
|
||||
EXIT_CODE="$(nvm_die_on_prefix 0 foo "${TEST_VERSION_DIR}" >/dev/null 2>&1; echo $?)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_die_on_prefix 0 foo' with global npmrc that has globalconfig did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||
[ "_$EXIT_CODE" = "_10" ] || die "'nvm_die_on_prefix 0 foo' with global npmrc that has globalconfig did not exit with 10; got '$EXIT_CODE'"
|
||||
|
||||
rm "${GLOBAL_NPMRC}" || die "${GLOBAL_NPMRC} could not be removed"
|
||||
|
||||
# builtin: prefix
|
||||
echo 'prefix=garbage' > "${BUILTIN_NPMRC}"
|
||||
OUTPUT="$(nvm_die_on_prefix 0 foo "${TEST_VERSION_DIR}" 2>&1)"
|
||||
EXPECTED_OUTPUT="Your builtin npmrc file ($(nvm_sanitize_path "${BUILTIN_NPMRC}"))
|
||||
has a \`globalconfig\` and/or a \`prefix\` setting, which are incompatible with nvm.
|
||||
Run \`foo\` to unset it."
|
||||
EXIT_CODE="$(nvm_die_on_prefix 0 foo "${TEST_VERSION_DIR}" >/dev/null 2>&1; echo $?)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_die_on_prefix 0 foo' with builtin npmrc that has prefix did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||
[ "_$EXIT_CODE" = "_10" ] || die "'nvm_die_on_prefix 0 foo' with builtin npmrc that has prefix did not exit with 10; got '$EXIT_CODE'"
|
||||
|
||||
# builtin: globalconfig
|
||||
echo 'globalconfig=garbage' > "${BUILTIN_NPMRC}"
|
||||
OUTPUT="$(nvm_die_on_prefix 0 foo "${TEST_VERSION_DIR}" 2>&1)"
|
||||
EXPECTED_OUTPUT="Your builtin npmrc file ($(nvm_sanitize_path "${BUILTIN_NPMRC}"))
|
||||
has a \`globalconfig\` and/or a \`prefix\` setting, which are incompatible with nvm.
|
||||
Run \`foo\` to unset it."
|
||||
EXIT_CODE="$(nvm_die_on_prefix 0 foo "${TEST_VERSION_DIR}" >/dev/null 2>&1; echo $?)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_die_on_prefix 0 foo' with builtin npmrc that has globalconfig did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||
[ "_$EXIT_CODE" = "_10" ] || die "'nvm_die_on_prefix 0 foo' with builtin npmrc that has globalconfig did not exit with 10; got '$EXIT_CODE'"
|
||||
|
||||
rm "${BUILTIN_NPMRC}" || die "${BUILTIN_NPMRC} could not be removed"
|
||||
|
||||
# user: prefix
|
||||
echo 'prefix=garbage' > "${USER_NPMRC}"
|
||||
OUTPUT="$(nvm_die_on_prefix 0 foo "${TEST_VERSION_DIR}" 2>&1)"
|
||||
EXPECTED_OUTPUT="Your user’s .npmrc file ($(nvm_sanitize_path "${USER_NPMRC}"))
|
||||
has a \`globalconfig\` and/or a \`prefix\` setting, which are incompatible with nvm.
|
||||
Run \`foo\` to unset it."
|
||||
EXIT_CODE="$(nvm_die_on_prefix 0 foo "${TEST_VERSION_DIR}" >/dev/null 2>&1; echo $?)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_die_on_prefix 0 foo' with user .npmrc that has prefix did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||
[ "_$EXIT_CODE" = "_10" ] || die "'nvm_die_on_prefix 0 foo' with user .npmrc that has prefix did not exit with 10; got '$EXIT_CODE'"
|
||||
|
||||
# user: globalconfig
|
||||
echo 'globalconfig=garbage' > "${USER_NPMRC}"
|
||||
OUTPUT="$(nvm_die_on_prefix 0 foo "${TEST_VERSION_DIR}" 2>&1)"
|
||||
EXPECTED_OUTPUT="Your user’s .npmrc file ($(nvm_sanitize_path "${USER_NPMRC}"))
|
||||
has a \`globalconfig\` and/or a \`prefix\` setting, which are incompatible with nvm.
|
||||
Run \`foo\` to unset it."
|
||||
EXIT_CODE="$(nvm_die_on_prefix 0 foo "${TEST_VERSION_DIR}" >/dev/null 2>&1; echo $?)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_die_on_prefix 0 foo' with user .npmrc that has globalconfig did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||
[ "_$EXIT_CODE" = "_10" ] || die "'nvm_die_on_prefix 0 foo' with user .npmrc that has globalconfig did not exit with 10; got '$EXIT_CODE'"
|
||||
)
|
||||
|
||||
cleanup
|
||||
|
||||
33
test/fast/Unit tests/nvm_find_project_dir
Executable file
33
test/fast/Unit tests/nvm_find_project_dir
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
set -ex
|
||||
|
||||
TEST_DIR="$PWD/mocks/project_dirs"
|
||||
|
||||
ACTUAL="$(PWD=$TEST_DIR/inside-n_m-nested/node_modules/foo/bar nvm_find_project_dir)"
|
||||
[ "${ACTUAL}" = "$TEST_DIR/inside-n_m-nested" ] || die "inside-n_m-nested: got ${ACTUAL}"
|
||||
|
||||
ACTUAL="$(PWD=$TEST_DIR/inside-n_m-nested-pkg/node_modules/foo/bar nvm_find_project_dir)"
|
||||
[ "${ACTUAL}" = "$TEST_DIR/inside-n_m-nested-pkg/node_modules/foo" ] || die "inside-n_m-nested-pkg: got ${ACTUAL}"
|
||||
|
||||
ACTUAL="$(PWD=$TEST_DIR/nested-both/a/b/c/d nvm_find_project_dir)"
|
||||
[ "${ACTUAL}" = "$TEST_DIR/nested-both" ] || die "nested-both: got ${ACTUAL}"
|
||||
|
||||
ACTUAL="$(PWD=$TEST_DIR/nested-pkg/a/b/c/d nvm_find_project_dir)"
|
||||
[ "${ACTUAL}" = "$TEST_DIR/nested-pkg" ] || die "nested-pkg: got ${ACTUAL}"
|
||||
|
||||
ACTUAL="$(PWD=$TEST_DIR/nested-n_m/a/b/c/d nvm_find_project_dir)"
|
||||
[ "${ACTUAL}" = "$TEST_DIR/nested-n_m" ] || die "nested-n_m: got ${ACTUAL}"
|
||||
|
||||
ACTUAL="$(PWD=$TEST_DIR/no-nesting-both nvm_find_project_dir)"
|
||||
[ "${ACTUAL}" = "$TEST_DIR/no-nesting-both" ] || die "no-nesting-both: got ${ACTUAL}"
|
||||
|
||||
ACTUAL="$(PWD=$TEST_DIR/no-nesting-n_m nvm_find_project_dir)"
|
||||
[ "${ACTUAL}" = "$TEST_DIR/no-nesting-n_m" ] || die "no-nesting-n_m: got ${ACTUAL}"
|
||||
|
||||
ACTUAL="$(PWD=$TEST_DIR/no-nesting-pkg nvm_find_project_dir)"
|
||||
[ "${ACTUAL}" = "$TEST_DIR/no-nesting-pkg" ] || die "no-nesting-pkg: got ${ACTUAL}"
|
||||
20
test/fast/Unit tests/nvm_get_checksum_binary
Executable file
20
test/fast/Unit tests/nvm_get_checksum_binary
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
set +e # TODO: fix
|
||||
\. ../../../nvm.sh
|
||||
set -e
|
||||
|
||||
BIN="$(nvm_get_checksum_binary)"
|
||||
|
||||
case "${BIN-}" in
|
||||
sha256sum | shasum | sha256 | gsha256sum | openssl | bssl | sha1sum | sha1 | shasum)
|
||||
echo "${BIN} found"
|
||||
;;
|
||||
*)
|
||||
die "sha256sum | shasum | sha256 | gsha256sum | openssl | bssl | sha1sum | sha1 | shasum not found: found ${BIN}"
|
||||
;;
|
||||
esac
|
||||
79
test/fast/Unit tests/nvm_get_colors
Executable file
79
test/fast/Unit tests/nvm_get_colors
Executable file
@@ -0,0 +1,79 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
die () { echo "$@" ; cleanup ; exit 1; }
|
||||
|
||||
cleanup() {
|
||||
unset NVM_COLORS
|
||||
if [ -n TEMP_NVM_COLORS ]; then
|
||||
export NVM_COLORS=TEMP_NVM_COLORS
|
||||
fi
|
||||
unset TEMP_NVM_COLORS
|
||||
}
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
# NVM_COLORS is not set
|
||||
if [ -n ${NVM_COLORS} ]; then
|
||||
export TEMP_NVM_COLORS=NVM_COLORS
|
||||
unset NVM_COLORS
|
||||
fi
|
||||
OUTPUT=$(nvm_get_colors 1)
|
||||
EXPECTED_OUTPUT='0;34m'
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_get_colors failed to return default color (INSTALLED_COLOR); got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<"
|
||||
|
||||
OUTPUT=$(nvm_get_colors 2)
|
||||
EXPECTED_OUTPUT='0;33m'
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_get_colors failed to return default color (SYSTEM_COLOR); got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<"
|
||||
|
||||
OUTPUT=$(nvm_get_colors 3)
|
||||
EXPECTED_OUTPUT='0;32m'
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_get_colors failed to return default color (CURRENT_COLOR); got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<"
|
||||
|
||||
OUTPUT=$(nvm_get_colors 4)
|
||||
EXPECTED_OUTPUT='0;31m'
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_get_colors failed to return default color (NOT_INSTALLED_COLOR); got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<"
|
||||
|
||||
OUTPUT=$(nvm_get_colors 5)
|
||||
EXPECTED_OUTPUT='0;37m'
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_get_colors failed to return default color (DEFAULT_COLOR); got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<"
|
||||
|
||||
OUTPUT=$(nvm_get_colors 6)
|
||||
EXPECTED_OUTPUT='1;33m'
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_get_colors failed to return default color (LTS_COLOR); got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<"
|
||||
|
||||
# bad parameter
|
||||
set +ex # needed for stderr
|
||||
OUTPUT=$(nvm_get_colors bad 2>&1)
|
||||
set -ex
|
||||
EXPECTED_OUTPUT="Invalid color index, bad"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_get_colors did not have an error with bad output; got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<"
|
||||
|
||||
# NVM_COLORS is set
|
||||
nvm set-colors rgbyc
|
||||
OUTPUT=$(nvm_get_colors 1)
|
||||
EXPECTED_OUTPUT='0;31m'
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_get_colors failed to return default color (INSTALLED_COLOR); got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<"
|
||||
|
||||
OUTPUT=$(nvm_get_colors 2)
|
||||
EXPECTED_OUTPUT='0;32m'
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_get_colors failed to return default color (SYSTEM_COLOR); got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<"
|
||||
|
||||
OUTPUT=$(nvm_get_colors 3)
|
||||
EXPECTED_OUTPUT='0;34m'
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_get_colors failed to return default color (CURRENT_COLOR); got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<"
|
||||
|
||||
OUTPUT=$(nvm_get_colors 4)
|
||||
EXPECTED_OUTPUT='0;33m'
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_get_colors failed to return default color (NOT_INSTALLED_COLOR); got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<"
|
||||
|
||||
OUTPUT=$(nvm_get_colors 5)
|
||||
EXPECTED_OUTPUT='0;36m'
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_get_colors failed to return default color (DEFAULT_COLOR); got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<"
|
||||
|
||||
OUTPUT=$(nvm_get_colors 6)
|
||||
EXPECTED_OUTPUT='1;32m'
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_get_colors failed to return default color (LTS_COLOR); got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<"
|
||||
|
||||
cleanup
|
||||
@@ -1,8 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
FILE="$NVM_DIR/default-packages"
|
||||
\. ../../../nvm.sh
|
||||
|
||||
FILE="$NVM_DIR/default-packages"
|
||||
|
||||
die () { echo "$@" ; cleanup ; exit 1; }
|
||||
setup () {
|
||||
if [ -f $FILE ]; then
|
||||
|
||||
17
test/fast/Unit tests/nvm_iojs_version_has_solaris_binary
Executable file
17
test/fast/Unit tests/nvm_iojs_version_has_solaris_binary
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
\. ../../../nvm.sh
|
||||
\. ../../common.sh
|
||||
|
||||
assert_not_ok nvm_iojs_version_has_solaris_binary ""
|
||||
assert_not_ok nvm_iojs_version_has_solaris_binary "foo"
|
||||
assert_not_ok nvm_iojs_version_has_solaris_binary "v1.1.0"
|
||||
|
||||
assert_ok nvm_iojs_version_has_solaris_binary "v3.3.1"
|
||||
assert_ok nvm_iojs_version_has_solaris_binary "iojs-v3.3.1"
|
||||
assert_ok nvm_iojs_version_has_solaris_binary "v3.3.2"
|
||||
assert_ok nvm_iojs_version_has_solaris_binary "iojs-v3.3.2"
|
||||
assert_ok nvm_iojs_version_has_solaris_binary "v3.4.1"
|
||||
assert_ok nvm_iojs_version_has_solaris_binary "iojs-v3.4.1"
|
||||
@@ -19,7 +19,8 @@ fi
|
||||
|
||||
rm -rf "$TEST_DIR"
|
||||
mkdir "$TEST_DIR"
|
||||
ln -s "$(command which which)" "$TEST_DIR/which"
|
||||
# Ensure that the system version of which is used, not node_modules/.bin/which
|
||||
ln -s "$(PATH=$(echo $PATH | tr ":" "\n" | grep -v "node_modules/.bin" | tr "\n" ":") command which which)" "$TEST_DIR/which"
|
||||
ln -s "$(command which dirname)" "$TEST_DIR/dirname"
|
||||
ln -s "$(command which printf)" "$TEST_DIR/printf"
|
||||
|
||||
@@ -27,12 +28,12 @@ ln -s "$(command which printf)" "$TEST_DIR/printf"
|
||||
[ "@$(PATH="$TEST_DIR" nvm_ls_current 2> /dev/stdout 1> /dev/null)@" = "@@" ] || die 'when node not installed, nvm_ls_current returned error output'
|
||||
|
||||
echo "#!/bin/bash" > "$TEST_DIR/node"
|
||||
echo "echo 'VERSION FOO!'" > "$TEST_DIR/node"
|
||||
echo "echo 'VERSION FOO!'" >> "$TEST_DIR/node"
|
||||
chmod a+x "$TEST_DIR/node"
|
||||
|
||||
[ "$(alias nvm_tree_contains_path='return_zero' && PATH="$TEST_DIR" nvm_ls_current)" = "VERSION FOO!" ] || die 'when activated, did not return nvm node version'
|
||||
[ "$(PATH="$TEST_DIR" nvm_ls_current)" = "VERSION FOO!" ] || die 'when activated, did not return nvm node version'
|
||||
|
||||
alias node='node --harmony'
|
||||
[ "$(alias nvm_tree_contains_path='return_zero' && PATH="$TEST_DIR" nvm_ls_current)" = "VERSION FOO!" ] || die 'when activated and node aliased, did not return nvm node version'
|
||||
[ "$(PATH="$TEST_DIR" nvm_ls_current)" = "VERSION FOO!" ] || die 'when activated and node aliased, did not return nvm node version'
|
||||
|
||||
cleanup
|
||||
|
||||
@@ -40,6 +40,19 @@ v0.3.8"
|
||||
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote 0.3 did not output 0.3.x versions; got $OUTPUT"
|
||||
|
||||
OUTPUT="$(nvm_ls_remote 0.3.)"
|
||||
EXPECTED_OUTPUT="v0.3.0
|
||||
v0.3.1
|
||||
v0.3.2
|
||||
v0.3.3
|
||||
v0.3.4
|
||||
v0.3.5
|
||||
v0.3.6
|
||||
v0.3.7
|
||||
v0.3.8"
|
||||
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote 0.3. did not output 0.3.x versions; got $OUTPUT"
|
||||
|
||||
# Sanity checks
|
||||
OUTPUT="$(nvm_print_implicit_alias remote stable)"
|
||||
EXPECTED_OUTPUT_PATH="${MOCKS_DIR}/nvm_print_implicit_alias remote stable.txt"
|
||||
|
||||
33
test/fast/Unit tests/nvm_node_version_has_solaris_binary
Executable file
33
test/fast/Unit tests/nvm_node_version_has_solaris_binary
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
\. ../../../nvm.sh
|
||||
\. ../../common.sh
|
||||
|
||||
# Invalid version numbers fail
|
||||
assert_not_ok nvm_node_version_has_solaris_binary ""
|
||||
assert_not_ok nvm_node_version_has_solaris_binary "foo"
|
||||
|
||||
# "Invalid" node version numbers fail
|
||||
assert_not_ok nvm_node_version_has_solaris_binary "v1.0.0"
|
||||
assert_not_ok nvm_node_version_has_solaris_binary "v3.3.1"
|
||||
|
||||
# Valid io.js version numbers that have a Solaris binary fail
|
||||
assert_not_ok nvm_node_version_has_solaris_binary "iojs-v3.3.1"
|
||||
|
||||
# Invalid io.js version numbers fail
|
||||
assert_not_ok nvm_node_version_has_solaris_binary "iojs-v0.12.7"
|
||||
|
||||
# Valid node version numbers that don't have a Solaris binary fail
|
||||
assert_not_ok nvm_node_version_has_solaris_binary "v0.8.5"
|
||||
|
||||
# Valid node version numbers that have a Solaris binary succeed
|
||||
assert_ok nvm_node_version_has_solaris_binary "v0.8.6"
|
||||
assert_ok nvm_node_version_has_solaris_binary "v0.10.0"
|
||||
assert_ok nvm_node_version_has_solaris_binary "v0.12.7"
|
||||
|
||||
# Valid "merged" version numbers fail, because they're not
|
||||
# considered node version numbers
|
||||
assert_not_ok nvm_node_version_has_solaris_binary "v4.0.0"
|
||||
assert_not_ok nvm_node_version_has_solaris_binary "v4.1.1"
|
||||
20
test/fast/Unit tests/nvm_print_color_code
Executable file
20
test/fast/Unit tests/nvm_print_color_code
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
# Testing valid input
|
||||
OUTPUT=$(nvm_print_color_code m)
|
||||
EXPECTED_OUTPUT='0;35m'
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_print_color_code returned wrong code; got $(echo ">$OUTPUT<") expected $(echo ">$EXPECTED_OUTPUT<")"
|
||||
|
||||
# Testing invalid input
|
||||
set +x # needed for stderr
|
||||
OUTPUT="$(nvm_print_color_code q 2>&1)" ||:
|
||||
set -x
|
||||
echo "OUTPUT WAS SET TO: $OUTPUT"
|
||||
EXPECTED_OUTPUT="Invalid color code"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_print_color_code did not recognize the invalid input; got $(echo ">$OUTPUT<") expected $(echo ">$EXPECTED_OUTPUT<")"
|
||||
@@ -7,6 +7,7 @@ die () { echo "$@" ; exit 1; }
|
||||
# Remove the stuff we're clobbering.
|
||||
[ -e "${NVM_DIR}/versions/node/v9.7.0" ] && rm -R "${NVM_DIR}/versions/node/v9.7.0"
|
||||
[ -e "${NVM_DIR}/versions/node/v9.10.0" ] && rm -R "${NVM_DIR}/versions/node/v9.10.0"
|
||||
[ -e "${NVM_DIR}/versions/node/v4.9.1" ] && rm -R "${NVM_DIR}/versions/node/v4.9.1"
|
||||
|
||||
# Install from binary
|
||||
nvm install 9.7.0
|
||||
@@ -31,3 +32,15 @@ nvm use 9
|
||||
node --version | grep v9.10.0 > /dev/null || die "nvm ls 9 didn't use v9.10.0"
|
||||
|
||||
npm list --global | grep object-is > /dev/null || die "object-is isn't installed"
|
||||
|
||||
|
||||
# LTS
|
||||
|
||||
nvm install --lts=argon --reinstall-packages-from=9 || die "nvm install 9.10.0 --reinstall-packages-from=9 failed"
|
||||
|
||||
[ -d "${NVM_DIR}/versions/node/v4.9.1" ] || die "nvm install 4.9.1 didn't install"
|
||||
|
||||
nvm use --lts=argon
|
||||
node --version | grep v4.9.1 > /dev/null || die "nvm ls --lts=argon didn't use v4.9.1"
|
||||
|
||||
npm list --global | grep object-is > /dev/null || die "object-is isn't installed"
|
||||
|
||||
11
test/installation_node/install with --alias
Executable file
11
test/installation_node/install with --alias
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
\. ../../nvm.sh
|
||||
|
||||
nvm install --alias=9 9.11.2 || die '`nvm install --alias=9 9.11.2` failed'
|
||||
|
||||
TERM=dumb nvm alias | grep '9 -> 9.11.2 (-> v9.11.2 \*)' || die 'did not make the expected alias'
|
||||
11
test/installation_node/install with --default
Executable file
11
test/installation_node/install with --default
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
\. ../../nvm.sh
|
||||
|
||||
nvm install --default node || die '`nvm install --default` failed'
|
||||
|
||||
TERM=dumb nvm alias | grep "default -> node (-> $(nvm version node) \*)" || die 'did not make the expected alias'
|
||||
@@ -10,8 +10,8 @@ nvm exec 0.10.29 npm install -g npm@~1.4.11 && nvm install-latest-npm # this is
|
||||
nvm use 0.10.28
|
||||
(cd test-npmlink && npm link)
|
||||
|
||||
EXPECTED_PACKAGES="autoprefixer bower david grunt-cli grunth-cli http-server jshint marked node-gyp npmlist recursive-blame spawn-sync test-npmlink uglify-js yo"
|
||||
EXPECTED_PACKAGES_INSTALL="autoprefixer bower david@11 grunt-cli grunth-cli http-server jshint marked node-gyp npmlist recursive-blame spawn-sync test-npmlink uglify-js yo@1"
|
||||
EXPECTED_PACKAGES="autoprefixer bower david grunt-cli grunth-cli http-server jshint marked node-gyp npmlist postcss recursive-blame spawn-sync test-npmlink uglify-js yo"
|
||||
EXPECTED_PACKAGES_INSTALL="autoprefixer bower david@11 grunt-cli grunth-cli http-server jshint marked node-gyp npmlist postcss@7 recursive-blame spawn-sync test-npmlink uglify-js yo@1"
|
||||
|
||||
echo "$EXPECTED_PACKAGES_INSTALL" | sed -e 's/test-npmlink //' | xargs npm install -g --quiet
|
||||
|
||||
|
||||
13
test/slow/nvm use/Running "nvm use node --silent" doesn't print anything
Executable file
13
test/slow/nvm use/Running "nvm use node --silent" doesn't print anything
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
nvm deactivate 2>&1 >/dev/null || die 'deactivate failed'
|
||||
|
||||
OUTPUT=$(nvm use node --silent || die 'nvm use node failed')
|
||||
EXPECTED_OUTPUT=""
|
||||
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|
||||
|| die "'nvm use node --silent' output was not silenced to '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||
Reference in New Issue
Block a user