Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: nvm-sh/nvm
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0880539ae04b4c416bd2851287bd49fe4aba3dea
Choose a base ref
..
head repository: nvm-sh/nvm
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 847cc1d9112c714a001b8aa3d483548a3c4d64c3
Choose a head ref
Showing with 392 additions and 80 deletions.
  1. +1 −0 .github/workflows/latest-npm.yml
  2. +4 −0 .github/workflows/lint.yml
  3. +57 −0 .github/workflows/tests.yml
  4. +0 −1 .travis.yml
  5. +1 −1 CODE_OF_CONDUCT.md
  6. +103 −7 CONTRIBUTING.md
  7. +45 −10 README.md
  8. +1 −1 install.sh
  9. +2 −2 nvm.sh
  10. +1 −1 package.json
  11. +2 −0 test/fast/Aliases/setup
  12. +2 −0 test/fast/Listing versions/Running 'nvm ls' should not show a trailing slash
  13. +2 −0 test/fast/Running 'nvm alias' should create a file in the alias directory
  14. +2 −0 test/fast/Running 'nvm current' should display current nvm environment
  15. +2 −0 test/fast/Running 'nvm deactivate' should unset the nvm environment variables
  16. +2 −0 test/fast/Running 'nvm install' with '--reinstall-packages-from' requires a valid version
  17. +2 −0 test/fast/Running 'nvm install' with an invalid version fails nicely
  18. +1 −0 test/fast/Unit tests/mocks/LTS_names.txt
  19. +1 −1 test/fast/Unit tests/mocks/lts-star.txt
  20. +12 −0 test/fast/Unit tests/mocks/nodejs.org-dist-index.tab
  21. +66 −27 test/fast/Unit tests/mocks/nodejs.org-download-nightly-index.tab
  22. +9 −2 test/fast/Unit tests/mocks/nvm ls-remote lts.txt
  23. +14 −2 test/fast/Unit tests/mocks/nvm ls-remote node.txt
  24. +14 −2 test/fast/Unit tests/mocks/nvm ls-remote.txt
  25. +9 −2 test/fast/Unit tests/mocks/nvm_ls_remote LTS.txt
  26. +2 −1 test/fast/Unit tests/mocks/nvm_ls_remote nightly.txt
  27. +1 −1 test/fast/Unit tests/mocks/nvm_ls_remote stable nightly.txt
  28. +1 −1 test/fast/Unit tests/mocks/nvm_ls_remote stable.txt
  29. +14 −2 test/fast/Unit tests/mocks/nvm_ls_remote.txt
  30. +4 −3 test/fast/Unit tests/mocks/nvm_make_alias LTS alias calls.txt
  31. +1 −1 test/fast/Unit tests/mocks/nvm_print_implicit_alias remote stable nightly.txt
  32. +1 −1 test/fast/Unit tests/mocks/nvm_print_implicit_alias remote stable.txt
  33. +2 −2 test/fast/Unit tests/nvm_download
  34. +9 −7 test/install_script/nvm_check_global_modules
  35. +2 −2 test/install_script/nvm_download
1 change: 1 addition & 0 deletions .github/workflows/latest-npm.yml
Original file line number Diff line number Diff line change
@@ -50,6 +50,7 @@ jobs:
with:
allowed-endpoints:
github.com:443
raw.githubusercontent.com:443
iojs.org:443
nodejs.org:443
registry.npmjs.org:443
4 changes: 4 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ jobs:
with:
allowed-endpoints:
github.com:443
raw.githubusercontent.com:443
nodejs.org:443
registry.npmjs.org:443
- uses: actions/checkout@v3
@@ -31,6 +32,7 @@ jobs:
allowed-endpoints:
ghcr.io:443
github.com:443
raw.githubusercontent.com:443
pkg-containers.githubusercontent.com:443
nodejs.org:443
registry.npmjs.org:443
@@ -50,6 +52,7 @@ jobs:
with:
allowed-endpoints:
github.com:443
raw.githubusercontent.com:443
nodejs.org:443
registry.npmjs.org:443
- uses: actions/checkout@v3
@@ -68,6 +71,7 @@ jobs:
with:
allowed-endpoints:
github.com:443
raw.githubusercontent.com:443
- uses: actions/checkout@v3
- name: check tests filenames
run: ./rename_test.sh --check
57 changes: 57 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: urchin tests

on: [push]

jobs:
tests:
permissions:
contents: write

name: "tests"
runs-on: ubuntu-latest
defaults:
run:
shell: 'script -q -e -c "${{ matrix.shell }} {0}"'

strategy:
fail-fast: false
matrix:
include:
- shell: bash
suite: install_script
# shell:
# - bash
# suite:
# - install_script

steps:
- name: Harden Runner
uses: step-security/harden-runner@v1
with:
allowed-endpoints:
github.com:443
registry.npmjs.org:443
raw.githubusercontent.com:443
nodejs.org:443
iojs.org:443
- uses: actions/checkout@v3
- run: sudo ${{ matrix.shell }} --version 2> /dev/null || dpkg -s ${{ matrix.shell }} 2> /dev/null || which ${{ matrix.shell }}
- run: curl --version
- run: wget --version
- uses: ljharb/actions/node/run@main
name: 'npm install && version checks'
with:
node-version: 'lts/*'
skip-ls-check: true
shell-command: echo installed
- run: npm ls urchin
- run: npm bin
- run: env
- run: make TERM=xterm-256color TEST_SUITE="${{ matrix.suite }}" SHELL="${{ matrix.shell }}" URCHIN="$(npm bin)/urchin" test-${{ matrix.shell }}

nvm:
name: 'all test suites, all shells'
needs: [tests]
runs-on: ubuntu-latest
steps:
- run: 'echo tests completed'
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -70,7 +70,6 @@ env:
- PATH="/usr/lib/ccache/:$PATH"
- NVM_DIR="${TRAVIS_BUILD_DIR}"
matrix:
- SHELL=bash TEST_SUITE=install_script
- SHELL=sh TEST_SUITE=fast
- SHELL=dash TEST_SUITE=fast
- SHELL=bash TEST_SUITE=fast
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ The OpenJS Foundation maintains a Code of Conduct Panel (CoCP).
This is a foundation-wide team established to manage escalation when a reporter believes that a report to a member project or the CPC has not been properly handled.
In order to escalate to the CoCP send an email to `coc-escalation@lists.openjsf.org`.

For more information, refer to the full [Code of Conduct governance document](https://github.com/openjs-foundation/cross-project-council/blob/master/CODE_OF_CONDUCT.md).
For more information, refer to the full [Code of Conduct governance document](https://github.com/openjs-foundation/cross-project-council/blob/HEAD/CODE_OF_CONDUCT.md).

---

110 changes: 103 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,117 @@
Thanks for contributing to `nvm`!
# Contributing

:+1::tada: First off, thanks for taking the time to contribute to `nvm`! :tada::+1:

We love pull requests and issues, they're our favorite.

The following is a set of guidelines for contributing to `nvm` managed by [@LJHarb](https://github.com/ljharb), which is hosted on GitHub. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.

However, before submitting, please review the following:

For bug reports:
# How Can I Contribute?

There are lots of ways to get involved. Here are some suggestions of things we'd love some help with.

## Resolving existing issues

You can consider helping out with issues already requiring attention - look for a "help wanted" label.

### How Do I Submit a (Good) Bug Report? :bug:

Explain the problem and include additional details to help maintainers reproduce the problem:

* **Use a clear and descriptive title** for the issue to identify the problem.

* **Describe the exact steps which reproduce the problem** in as many details as possible. For example, start by explaining which command exactly you used in the terminal. When listing steps, **don't just say what you did, but explain how you did it**. For example, if you moved the cursor to the end of a line, explain if you used the mouse, or a keyboard shortcut or a command, and if so which one?
* **Provide specific examples to demonstrate the steps**. Include links to files or Github projects, or copy/pasteable snippets, which you use in those examples. If you're providing snippets in the issue, use [Markdown code blocks](https://help.github.com/articles/markdown-basics/#multiple-lines).
* **Describe the behavior you observed after following the steps** and point out what exactly is the problem with that behavior.
* **Explain which behavior you expected to see instead and why.**
* **Provide as much context as possible** in order to help others verify and ultimately fix the issue. This includes giving us as much details as possible about your environment, so we can more easily confirm the problem.

- Please make sure the bug is reproducible, and give us the steps to reproduce it, so that we can dig into the problem.
- Please give us as much detail as possible about your environment, so we can more easily confirm the problem.
## Documentation

For pull requests:
We are happy to welcome contributions from anyone willing to improve documentation by adding missing information or making it more consistent and coherent.

# Dev Environment

Please refer to the [README](README.md) for complete instructions how to install, update, as well as troubleshoot `nvm` in your environment depending on your Operating System.

# Style Guide / Coding conventions

### Pull requests

#### Before creating a pull request

- Please include tests. Changes with tests will be merged very quickly.
- Please manually confirm that your changes work in `bash`, `sh`/`dash`, `ksh`, and `zsh`. Fast tests do run in these shells, but it's nice to manually verify also.
- Please maintain consistent whitespace - 2-space indentation, trailing newlines in all files, etc.
- Any time you make a change to your PR, please rebase freshly on top of master. Nobody likes merge commits.
- Any time you make a change to your PR, please rebase freshly on top of the default branch. Nobody likes merge commits.

Even if you don't have all of these items covered, please still feel free to submit a PR/issue! Someone else may be inspired and volunteer to complete it for you.

Thanks again!
#### How to create a pull request

Create a new branch

```
git checkout -b issue1234
```

Commit the changes to your branch, including a coherent commit message that follows our [standards](#commit-messages)

```
git commit -a
```

Before sending the pull request, make sure your code is running on the latest available code by rebasing onto the upstream source

```
git fetch upstream
git rebase upstream/main
```

Verify your changes

```
npm test
# or
npm run tests-only
```

Push your changes

```
git push origin issue1234
```

Send the [pull request](https://docs.github.com/en/pull-requests), make requested changes, and get merged.

### Commit Messages

* Limit the first line of the commit message (message summary) to 72 characters or less.
* Use the present tense ("Add feature" not "Added feature") and imperative mood ("Move cursor to..." not "Moves cursor to...") when providing a description of what you did.
* If your PR addresses an issue, reference it in the body of the commit message.
* See the rest of the conventions [here](https://gist.github.com/ljharb/772b0334387a4bee89af24183114b3c7)

#### Commit message example

```
[Tag]: Short description of what you did
Longer description here if necessary
Fixes #1234
```

> **Note:** Add co-authors to your commit message for commits with multiple authors
```
Co-authored-by: Name Here <email@here>
```


# Code of Conduct
[Code of Conduct](https://github.com/nvm-sh/nvm/blob/HEAD/CODE_OF_CONDUCT.md)

# Where can I ask for help?
If you have any questions, please contact [@LJHarb](mailto:ljharb@gmail.com).
55 changes: 45 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<a href="https://github.com/nvm-sh/logos"><img alt="nvm project logo" src="https://raw.githubusercontent.com/nvm-sh/logos/HEAD/nvm-logo-color.svg" height="50" /></a>

# Node Version Manager [![Build Status](https://travis-ci.org/nvm-sh/nvm.svg?branch=master)][3] [![nvm version](https://img.shields.io/badge/version-v0.39.2-yellow.svg)][4] [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/684/badge)](https://bestpractices.coreinfrastructure.org/projects/684)
# Node Version Manager [![Build Status](https://travis-ci.org/nvm-sh/nvm.svg?branch=master)][3] [![nvm version](https://img.shields.io/badge/version-v0.39.3-yellow.svg)][4] [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/684/badge)](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 -->
@@ -54,6 +54,7 @@
- [Docker For Development Environment](#docker-for-development-environment)
- [Problems](#problems)
- [macOS Troubleshooting](#macos-troubleshooting)
- [WSL Troubleshooting](#wsl-troubleshooting)
- [Maintainers](#maintainers)
- [License](#license)
- [Copyright notice](#copyright-notice)
@@ -94,10 +95,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.39.2/install.sh | bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
```
```sh
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/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`).
@@ -165,7 +166,7 @@ You can use a task:
```yaml
- name: Install nvm
ansible.builtin.shell: >
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
args:
creates: "{{ ansible_env.HOME }}/.nvm/nvm.sh"
```
@@ -227,7 +228,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.39.2`
1. `cd ~/.nvm` and check out the latest version with `git checkout v0.39.3`
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:
@@ -793,13 +794,13 @@ If installing nvm on Alpine Linux *is* still what you want or need to do, you sh
### Alpine Linux 3.13+
```sh
apk add -U curl bash ca-certificates openssl ncurses coreutils python3 make gcc g++ libgcc linux-headers grep util-linux binutils findutils
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
```
### Alpine Linux 3.5 - 3.12
```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.39.2/install.sh | bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
```
_Note: Alpine 3.5 can only install NodeJS versions up to v6.9.5, Alpine 3.6 can only install versions up to v6.10.3, Alpine 3.7 installs versions up to v8.9.3, Alpine 3.8 installs versions up to v8.14.0, Alpine 3.9 installs versions up to v10.19.0, Alpine 3.10 installs versions up to v10.24.1, Alpine 3.11 installs versions up to v12.22.6, Alpine 3.12 installs versions up to v12.22.12, Alpine 3.13 & 3.14 install versions up to v14.20.0, Alpine 3.15 & 3.16 install versions up to v16.16.0 (**These are all versions on the main branch**). Alpine 3.5 - 3.12 required the package `python2` to build NodeJS, as they are older versions to build. Alpine 3.13+ requires `python3` to successfully build newer NodeJS versions, but you can use `python2` with Alpine 3.13+ if you need to build versions of node supported in Alpine 3.5 - 3.15, you just need to specify what version of NodeJS you need to install in the package install script._
@@ -898,10 +899,10 @@ You have to make sure that the user directory name in `$HOME` and the user direc
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.39.2/install.sh
[2]: https://github.com/nvm-sh/nvm/blob/v0.39.3/install.sh
[3]: https://travis-ci.org/nvm-sh/nvm
[4]: https://github.com/nvm-sh/nvm/releases/tag/v0.39.2
[Urchin]: https://github.com/scraperwiki/urchin
[4]: https://github.com/nvm-sh/nvm/releases/tag/v0.39.3
[Urchin]: https://git.sdf.org/tlevine/urchin
[Fish]: https://fishshell.com
**Homebrew makes zsh directories unsecure**
@@ -980,6 +981,40 @@ Here's what you will need to do:
Now you should be able to use node as usual.
## WSL Troubleshooting
If you've encountered this error on WSL-2:
```sh
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:09 --:--:-- 0curl: (6) Could not resolve host: raw.githubusercontent.com
```
It may be due to your antivirus, VPN, or other reasons.
Where you can `ping 8.8.8.8` while you can't `ping google.com`
This could simply be solved by running this in your root directory:
```sh
sudo rm /etc/resolv.conf
sudo bash -c 'echo "nameserver 8.8.8.8" > /etc/resolv.conf'
sudo bash -c 'echo "[network]" > /etc/wsl.conf'
sudo bash -c 'echo "generateResolvConf = false" >> /etc/wsl.conf'
sudo chattr +i /etc/resolv.conf
```
This deletes your `resolve.conf` file thats automatically generated when u run WSL, creates a new file and puts `nameserver 8.8.8.8`, then creates a `wsl.conf` file and adds `[network]` and `generateResolveConf = false` to prevent auto generation of that file.
You can check the contents of the file by running:
```sh
cat /etc/resolv.conf
```
## Maintainers
Currently, the sole maintainer is [@ljharb](https://github.com/ljharb) - more maintainers are quite welcome, and we hope to add folks to the team over time. [Governance](./GOVERNANCE.md) will be re-evaluated as the project evolves.
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ nvm_install_dir() {
}

nvm_latest_version() {
nvm_echo "v0.39.2"
nvm_echo "v0.39.3"
}

nvm_profile_is_bash_or_zsh() {
4 changes: 2 additions & 2 deletions nvm.sh
Original file line number Diff line number Diff line change
@@ -87,7 +87,7 @@ nvm_has_colors() {
}

nvm_curl_libz_support() {
command curl -V 2>/dev/null | nvm_grep "^Features:" | nvm_grep -q "libz"
curl -V 2>/dev/null | nvm_grep "^Features:" | nvm_grep -q "libz"
}

nvm_curl_use_compression() {
@@ -4165,7 +4165,7 @@ nvm() {
NVM_VERSION_ONLY=true NVM_LTS="${NVM_LTS-}" nvm_remote_version "${PATTERN:-node}"
;;
"--version" | "-v")
nvm_echo '0.39.2'
nvm_echo '0.39.3'
;;
"unload")
nvm deactivate >/dev/null 2>&1
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nvm",
"version": "0.39.2",
"version": "0.39.3",
"description": "Node Version Manager - Simple bash script to manage multiple active node.js versions",
"directories": {
"test": "test"
Loading