mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-05-10 14:21:50 +00:00
Merge branch 'nvm-sh:master' into master
This commit is contained in:
commit
c61fe89d72
@ -1,9 +1,9 @@
|
||||
# Code of Conduct
|
||||
|
||||
`nvm`, as a member project of the OpenJS Foundation, uses [Contributor Covenant v1.4](https://www.contributor-covenant.org/version/1/4/code-of-conduct) as their code of conduct. The full text is included [below](#contributor-covenant-code-of-conduct) in English, and translations are available from the Contributor Covenant organisation:
|
||||
`nvm`, as a member project of the OpenJS Foundation, uses [Contributor Covenant v2.1](https://www.contributor-covenant.org/version/2/1/code_of_conduct/) as their code of conduct. The full text is included [below](#contributor-covenant-code-of-conduct) in English, and translations are available from the Contributor Covenant organisation:
|
||||
|
||||
- [contributor-covenant.org/translations](https://www.contributor-covenant.org/translations)
|
||||
- [github.com/ContributorCovenant](https://github.com/ContributorCovenant/contributor_covenant/tree/release/content/version/1/4)
|
||||
- [github.com/ContributorCovenant](https://github.com/ContributorCovenant/contributor_covenant/tree/release/content/version/2/1)
|
||||
|
||||
Refer to the sections on reporting and escalation in this document for the specific emails that can be used to report and escalate issues.
|
||||
|
||||
@ -14,93 +14,112 @@ Refer to the sections on reporting and escalation in this document for the speci
|
||||
For reporting issues in spaces related to `nvm` please use the email `ljharb@gmail.com`. `nvm` handles CoC issues related to the spaces that it maintains. Projects maintainers commit to:
|
||||
|
||||
- maintain the confidentiality with regard to the reporter of an incident
|
||||
- to participate in the path for escalation as outlined in
|
||||
the section on Escalation when required.
|
||||
- to participate in the path for escalation as outlined in the section on Escalation when required.
|
||||
|
||||
### Foundation Spaces
|
||||
|
||||
For reporting issues in spaces managed by the OpenJS Foundation, for example, repositories within the OpenJS organization, use the email `report@lists.openjsf.org`. The Cross Project Council (CPC) is responsible for managing these reports and commits to:
|
||||
For reporting issues in spaces managed by the OpenJS Foundation, for example, repositories within the OpenJS organization, use the email `report@lists.openjsf.org`.
|
||||
The Cross Project Council (CPC) is responsible for managing these reports and commits to:
|
||||
|
||||
- maintain the confidentiality with regard to the reporter of an incident
|
||||
- to participate in the path for escalation as outlined in
|
||||
the section on Escalation when required.
|
||||
- to participate in the path for escalation as outlined in the section on Escalation when required.
|
||||
|
||||
## Escalation
|
||||
|
||||
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`.
|
||||
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).
|
||||
|
||||
---
|
||||
|
||||
## Contributor Covenant Code of Conduct
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
### Our Pledge
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, gender identity and expression, level of experience,
|
||||
nationality, personal appearance, race, religion, or sexual identity and
|
||||
orientation.
|
||||
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
|
||||
|
||||
### Our Standards
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment include:
|
||||
## Our Standards
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
Examples of behavior that contributes to a positive environment for our community include:
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
* Demonstrating empathy and kindness toward other people
|
||||
* Being respectful of differing opinions, viewpoints, and experiences
|
||||
* Giving and gracefully accepting constructive feedback
|
||||
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
||||
* Focusing on what is best not just for us as individuals, but for the overall community
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
* The use of sexualized language or imagery, and sexual attention or advances of any kind
|
||||
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
||||
* Publishing others' private information, such as a physical or email address, without their explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||
|
||||
### Our Responsibilities
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
||||
|
||||
### Scope
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces.
|
||||
Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
||||
|
||||
### Enforcement
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at the email addresses listed above in
|
||||
the [Reporting](#reporting) and [Escalation](#escalation) sections. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an
|
||||
incident. Further details of specific enforcement policies may be posted
|
||||
separately.
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [@ljharb](ljharb@gmail.com).
|
||||
All complaints will be reviewed and investigated promptly and fairly.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
||||
|
||||
## Enforcement Guidelines
|
||||
|
||||
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
||||
|
||||
### 1. Correction
|
||||
|
||||
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
||||
|
||||
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
### 2. Warning
|
||||
|
||||
**Community Impact**: A violation through a single incident or series of actions.
|
||||
|
||||
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
||||
|
||||
### 3. Temporary Ban
|
||||
|
||||
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
||||
|
||||
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
||||
|
||||
### 4. Permanent Ban
|
||||
|
||||
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at [https://www.contributor-covenant.org/version/1/4/code-of-conduct/](https://www.contributor-covenant.org/version/1/4/code-of-conduct/)
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at
|
||||
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
||||
|
||||
Community Impact Guidelines were inspired by
|
||||
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
||||
|
||||
For answers to common questions about this code of conduct, see the FAQ at
|
||||
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
||||
[https://www.contributor-covenant.org/translations][translations].
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
||||
[Mozilla CoC]: https://github.com/mozilla/diversity
|
||||
[FAQ]: https://www.contributor-covenant.org/faq
|
||||
[translations]: https://www.contributor-covenant.org/translations
|
||||
|
36
README.md
36
README.md
@ -1,3 +1,5 @@
|
||||
<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 [][3] [][4] [](https://bestpractices.coreinfrastructure.org/projects/684)
|
||||
|
||||
<!-- To update this table of contents, ensure you have run `npm install` then `npm run doctoc` -->
|
||||
@ -203,7 +205,7 @@ If you're running a system without prepackaged binary available, which means you
|
||||
|
||||
**Note:** On OS X, if you do not have Xcode installed and you do not wish to download the ~4.3GB file, you can install the `Command Line Tools`. You can check out this blog post on how to just that:
|
||||
|
||||
- [How to Install Command Line Tools in OS X Mavericks & Yosemite (Without Xcode)](http://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/)
|
||||
- [How to Install Command Line Tools in OS X Mavericks & Yosemite (Without Xcode)](https://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/)
|
||||
|
||||
**Note:** On OS X, if you have/had a "system" node installed and want to install modules globally, keep in mind that:
|
||||
|
||||
@ -459,7 +461,7 @@ 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:
|
||||
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'
|
||||
@ -655,7 +657,7 @@ function load_nvm --on-variable="PWD"
|
||||
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
|
||||
else if test "$nvmrc_node_version" != "$node_version"
|
||||
nvm use $nvmrc_node_version
|
||||
end
|
||||
else if test "$node_version" != "$default_node_version"
|
||||
@ -666,7 +668,7 @@ end
|
||||
|
||||
# ~/.config/fish/config.fish
|
||||
# You must call it on initialization or listening to directory switching won't work
|
||||
load_nvm
|
||||
load_nvm > /dev/stderr
|
||||
```
|
||||
|
||||
## Running Tests
|
||||
@ -718,36 +720,36 @@ Put the above sourcing line just below the sourcing line for nvm in your profile
|
||||
### Usage
|
||||
|
||||
nvm:
|
||||
> $ nvm <kbd>Tab</kbd>
|
||||
|
||||
```
|
||||
> `$ nvm` <kbd>Tab</kbd>
|
||||
```sh
|
||||
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>
|
||||
|
||||
```
|
||||
> `$ nvm alias` <kbd>Tab</kbd>
|
||||
```sh
|
||||
default iojs lts/* lts/argon lts/boron lts/carbon lts/dubnium lts/erbium node stable unstable
|
||||
```
|
||||
|
||||
> $ nvm alias my_alias <kbd>Tab</kbd>
|
||||
|
||||
```
|
||||
> `$ nvm alias my_alias` <kbd>Tab</kbd>
|
||||
```sh
|
||||
v10.22.0 v12.18.3 v14.8.0
|
||||
```
|
||||
|
||||
nvm use:
|
||||
> $ nvm use <kbd>Tab</kbd>
|
||||
> `$ nvm use` <kbd>Tab</kbd>
|
||||
|
||||
```
|
||||
my_alias default v10.22.0 v12.18.3 v14.8.0
|
||||
```
|
||||
|
||||
nvm uninstall:
|
||||
> $ nvm uninstall <kbd>Tab</kbd>
|
||||
> `$ nvm uninstall` <kbd>Tab</kbd>
|
||||
|
||||
```
|
||||
my_alias default v10.22.0 v12.18.3 v14.8.0
|
||||
@ -779,7 +781,7 @@ set -e
|
||||
|
||||
## Installing nvm on Alpine Linux
|
||||
|
||||
In order to provide the best performance (and other optimisations), nvm will download and install pre-compiled binaries for Node (and npm) when you run `nvm install X`. The Node project compiles, tests and hosts/provides these pre-compiled binaries which are built for mainstream/traditional Linux distributions (such as Debian, Ubuntu, CentOS, RedHat et al).
|
||||
In order to provide the best performance (and other optimizations), nvm will download and install pre-compiled binaries for Node (and npm) when you run `nvm install X`. The Node project compiles, tests and hosts/provides these pre-compiled binaries which are built for mainstream/traditional Linux distributions (such as Debian, Ubuntu, CentOS, RedHat et al).
|
||||
|
||||
Alpine Linux, unlike mainstream/traditional Linux distributions, is based on [BusyBox](https://www.busybox.net/), a very compact (~5MB) Linux distribution. BusyBox (and thus Alpine Linux) uses a different C/C++ stack to most mainstream/traditional Linux distributions - [musl](https://www.musl-libc.org/). This makes binary programs built for such mainstream/traditional incompatible with Alpine Linux, thus we cannot simply `nvm install X` on Alpine Linux and expect the downloaded binary to run correctly - you'll likely see "...does not exist" errors if you try that.
|
||||
|
||||
@ -890,7 +892,7 @@ To change the user directory and/or account name follow the instructions [here](
|
||||
[3]: https://travis-ci.org/nvm-sh/nvm
|
||||
[4]: https://github.com/nvm-sh/nvm/releases/tag/v0.39.1
|
||||
[Urchin]: https://github.com/scraperwiki/urchin
|
||||
[Fish]: http://fishshell.com
|
||||
[Fish]: https://fishshell.com
|
||||
|
||||
**Homebrew makes zsh directories unsecure**
|
||||
|
||||
@ -906,7 +908,7 @@ Homebrew causes insecure directories like `/usr/local/share/zsh/site-functions`
|
||||
Experimental support for the M1 architecture was added in node.js v15.3 and full support was added in v16.0.
|
||||
Because of this, if you try to install older versions of node as usual, you will probably experience either compilation errors when installing node or out-of-memory errors while running your code.
|
||||
|
||||
So, if you want to run a version prior to v16.0 on an M1 Mac, it may be best to compile node targeting the x86_64 Intel architecture so that Rosetta 2 can translate the x86_64 processor instructions to ARM-based Apple Silicon instructions.
|
||||
So, if you want to run a version prior to v16.0 on an M1 Mac, it may be best to compile node targeting the `x86_64` Intel architecture so that Rosetta 2 can translate the `x86_64` processor instructions to ARM-based Apple Silicon instructions.
|
||||
Here's what you will need to do:
|
||||
|
||||
- Install Rosetta, if you haven't already done so
|
||||
@ -931,7 +933,7 @@ Here's what you will need to do:
|
||||
If that's the case, make sure to source `nvm`.
|
||||
|
||||
```sh
|
||||
$ source "${NVM_DIR}/.nvm/nvm.sh"
|
||||
$ source "${NVM_DIR}/nvm.sh"
|
||||
```
|
||||
|
||||
- Install whatever older version of node you are interested in. Let's use 12.22.1 as an example.
|
||||
@ -959,7 +961,7 @@ Here's what you will need to do:
|
||||
Note: If you selected the box labeled "Open using Rosetta" rather than running the CLI command in the second step, you will see `i386` here.
|
||||
Unless you have another reason to have that box selected, you can deselect it now.
|
||||
|
||||
- Check to make sure the architecture is correct. `x64` is the abbreviation for x86_64, which is what you want to see.
|
||||
- Check to make sure the architecture is correct. `x64` is the abbreviation for `x86_64`, which is what you want to see.
|
||||
|
||||
```sh
|
||||
$ node -p process.arch
|
||||
|
12
install.sh
12
install.sh
@ -10,6 +10,12 @@ nvm_echo() {
|
||||
command printf %s\\n "$*" 2>/dev/null
|
||||
}
|
||||
|
||||
if [ -z "${BASH_VERSION}" ] || [ -n "${ZSH_VERSION}" ]; then
|
||||
# shellcheck disable=SC2016
|
||||
nvm_echo >&2 'Error: the install instructions explicitly say to pipe the install script to `bash`; please follow them'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
nvm_grep() {
|
||||
GREP_OPTIONS='' command grep "$@"
|
||||
}
|
||||
@ -356,6 +362,12 @@ nvm_do_install() {
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
if nvm_has xcode-select && [ "$(xcode-select -p >/dev/null 2>/dev/null ; echo $?)" = '2' ] && [ "$(which git)" = '/usr/bin/git' ] && [ "$(which curl)" = '/usr/bin/curl' ]; then
|
||||
nvm_echo >&2 'You may be on a Mac, and need to install the Xcode Command Line Developer Tools.'
|
||||
# shellcheck disable=SC2016
|
||||
nvm_echo >&2 'If so, run `xcode-select --install` and try again. If not, please report this!'
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "${METHOD}" ]; then
|
||||
# Autodetect install method
|
||||
if nvm_has git; then
|
||||
|
47
nvm.sh
47
nvm.sh
@ -101,15 +101,15 @@ nvm_get_latest() {
|
||||
if nvm_curl_use_compression; then
|
||||
CURL_COMPRESSED_FLAG="--compressed"
|
||||
fi
|
||||
NVM_LATEST_URL="$(curl ${CURL_COMPRESSED_FLAG:-} -q -w "%{url_effective}\\n" -L -s -S http://latest.nvm.sh -o /dev/null)"
|
||||
NVM_LATEST_URL="$(curl ${CURL_COMPRESSED_FLAG:-} -q -w "%{url_effective}\\n" -L -s -S https://latest.nvm.sh -o /dev/null)"
|
||||
elif nvm_has "wget"; then
|
||||
NVM_LATEST_URL="$(wget -q http://latest.nvm.sh --server-response -O /dev/null 2>&1 | command awk '/^ Location: /{DEST=$2} END{ print DEST }')"
|
||||
NVM_LATEST_URL="$(wget -q https://latest.nvm.sh --server-response -O /dev/null 2>&1 | command awk '/^ Location: /{DEST=$2} END{ print DEST }')"
|
||||
else
|
||||
nvm_err 'nvm needs curl or wget to proceed.'
|
||||
return 1
|
||||
fi
|
||||
if [ -z "${NVM_LATEST_URL}" ]; then
|
||||
nvm_err "http://latest.nvm.sh did not redirect to the latest release on GitHub"
|
||||
nvm_err "https://latest.nvm.sh did not redirect to the latest release on GitHub"
|
||||
return 2
|
||||
fi
|
||||
nvm_echo "${NVM_LATEST_URL##*/}"
|
||||
@ -506,6 +506,8 @@ nvm_version_path() {
|
||||
nvm_ensure_version_installed() {
|
||||
local PROVIDED_VERSION
|
||||
PROVIDED_VERSION="${1-}"
|
||||
local IS_VERSION_FROM_NVMRC
|
||||
IS_VERSION_FROM_NVMRC="${2-}"
|
||||
if [ "${PROVIDED_VERSION}" = 'system' ]; then
|
||||
if nvm_has_system_iojs || nvm_has_system_node; then
|
||||
return 0
|
||||
@ -527,7 +529,11 @@ nvm_ensure_version_installed() {
|
||||
nvm_err "N/A: version \"${PREFIXED_VERSION:-$PROVIDED_VERSION}\" is not yet installed."
|
||||
fi
|
||||
nvm_err ""
|
||||
nvm_err "You need to run \"nvm install ${PROVIDED_VERSION}\" to install it before using it."
|
||||
if [ "${IS_VERSION_FROM_NVMRC}" != '1' ]; then
|
||||
nvm_err "You need to run \`nvm install ${PROVIDED_VERSION}\` to install and use it."
|
||||
else
|
||||
nvm_err 'You need to run `nvm install` to install and use the node version specified in `.nvmrc`.'
|
||||
fi
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
@ -1870,9 +1876,12 @@ nvm_get_arch() {
|
||||
*) NVM_ARCH="${HOST_ARCH}" ;;
|
||||
esac
|
||||
|
||||
# If running a 64bit ARM kernel but a 32bit ARM userland, change ARCH to 32bit ARM (armv7l)
|
||||
L=$(ls -dl /sbin/init 2>/dev/null) # if /sbin/init is 32bit executable
|
||||
if [ "$(uname)" = "Linux" ] && [ "${NVM_ARCH}" = arm64 ] && [ "$(od -An -t x1 -j 4 -N 1 "${L#*-> }")" = ' 01' ]; then
|
||||
# If running a 64bit ARM kernel but a 32bit ARM userland,
|
||||
# change ARCH to 32bit ARM (armv7l) if /sbin/init is 32bit executable
|
||||
local L
|
||||
if [ "$(uname)" = "Linux" ] && [ "${NVM_ARCH}" = arm64 ] &&
|
||||
L="$(command ls -dl /sbin/init 2>/dev/null)" &&
|
||||
[ "$(od -An -t x1 -j 4 -N 1 "${L#*-> }")" = ' 01' ]; then
|
||||
NVM_ARCH=armv7l
|
||||
HOST_ARCH=armv7l
|
||||
fi
|
||||
@ -2741,6 +2750,15 @@ nvm() {
|
||||
EXIT_CODE="$?"
|
||||
set -a
|
||||
return "$EXIT_CODE"
|
||||
elif [ -n "${BASH-}" ] && [ "${-#*E}" != "$-" ]; then
|
||||
# shellcheck disable=SC3041
|
||||
set +E
|
||||
local EXIT_CODE
|
||||
IFS="${DEFAULT_IFS}" nvm "$@"
|
||||
EXIT_CODE="$?"
|
||||
# shellcheck disable=SC3041
|
||||
set -E
|
||||
return "$EXIT_CODE"
|
||||
elif [ "${IFS}" != "${DEFAULT_IFS}" ]; then
|
||||
IFS="${DEFAULT_IFS}" nvm "$@"
|
||||
return "$?"
|
||||
@ -3510,6 +3528,8 @@ nvm() {
|
||||
local NVM_DELETE_PREFIX
|
||||
NVM_DELETE_PREFIX=0
|
||||
local NVM_LTS
|
||||
local IS_VERSION_FROM_NVMRC
|
||||
IS_VERSION_FROM_NVMRC=0
|
||||
|
||||
while [ $# -ne 0 ]; do
|
||||
case "$1" in
|
||||
@ -3537,6 +3557,7 @@ nvm() {
|
||||
NVM_SILENT="${NVM_SILENT:-0}" nvm_rc_version
|
||||
if [ -n "${NVM_RC_VERSION-}" ]; then
|
||||
PROVIDED_VERSION="${NVM_RC_VERSION}"
|
||||
IS_VERSION_FROM_NVMRC=1
|
||||
VERSION="$(nvm_version "${PROVIDED_VERSION}")"
|
||||
fi
|
||||
unset NVM_RC_VERSION
|
||||
@ -3576,14 +3597,12 @@ nvm() {
|
||||
fi
|
||||
if [ "${VERSION}" = 'N/A' ]; then
|
||||
if [ "${NVM_SILENT:-0}" -ne 1 ]; then
|
||||
nvm_err "N/A: version \"${PROVIDED_VERSION} -> ${VERSION}\" is not yet installed."
|
||||
nvm_err ""
|
||||
nvm_err "You need to run \"nvm install ${PROVIDED_VERSION}\" to install it before using it."
|
||||
nvm_ensure_version_installed "${PROVIDED_VERSION}" "${IS_VERSION_FROM_NVMRC}"
|
||||
fi
|
||||
return 3
|
||||
# This nvm_ensure_version_installed call can be a performance bottleneck
|
||||
# on shell startup. Perhaps we can optimize it away or make it faster.
|
||||
elif ! nvm_ensure_version_installed "${VERSION}"; then
|
||||
elif ! nvm_ensure_version_installed "${VERSION}" "${IS_VERSION_FROM_NVMRC}"; then
|
||||
return $?
|
||||
fi
|
||||
|
||||
@ -3638,6 +3657,8 @@ nvm() {
|
||||
local provided_version
|
||||
local has_checked_nvmrc
|
||||
has_checked_nvmrc=0
|
||||
local IS_VERSION_FROM_NVMRC
|
||||
IS_VERSION_FROM_NVMRC=0
|
||||
# run given version of node
|
||||
|
||||
local NVM_SILENT
|
||||
@ -3683,6 +3704,8 @@ nvm() {
|
||||
if [ $has_checked_nvmrc -ne 1 ]; then
|
||||
NVM_SILENT="${NVM_SILENT:-0}" nvm_rc_version && has_checked_nvmrc=1
|
||||
fi
|
||||
provided_version="${NVM_RC_VERSION}"
|
||||
IS_VERSION_FROM_NVMRC=1
|
||||
VERSION="$(nvm_version "${NVM_RC_VERSION}")" ||:
|
||||
unset NVM_RC_VERSION
|
||||
else
|
||||
@ -3705,7 +3728,7 @@ nvm() {
|
||||
VERSION=''
|
||||
fi
|
||||
if [ "_${VERSION}" = "_N/A" ]; then
|
||||
nvm_ensure_version_installed "${provided_version}"
|
||||
nvm_ensure_version_installed "${provided_version}" "${IS_VERSION_FROM_NVMRC}"
|
||||
elif [ "${NVM_IOJS}" = true ]; then
|
||||
nvm exec "${NVM_SILENT_ARG-}" "${LTS_ARG-}" "${VERSION}" iojs "$@"
|
||||
else
|
||||
|
@ -15,7 +15,16 @@ OUTPUT="$(nvm_ensure_version_installed foo 2>&1)"
|
||||
EXIT_CODE=$?
|
||||
EXPECTED_OUTPUT='N/A: version "foo" is not yet installed.
|
||||
|
||||
You need to run "nvm install foo" to install it before using it.'
|
||||
You need to run `nvm install foo` to install and use it.'
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "expected 'nvm_ensure_version_installed foo' to give $EXPECTED_OUTPUT, got $OUTPUT"
|
||||
[ "_$EXIT_CODE" = "_1" ] || die "expected 'nvm_ensure_version_installed foo' to exit with 1, got $EXIT_CODE"
|
||||
|
||||
# Case when .nvmrc file is opened, we should be skip showing the version
|
||||
OUTPUT="$(nvm_ensure_version_installed foo 1 2>&1)"
|
||||
EXIT_CODE=$?
|
||||
EXPECTED_OUTPUT='N/A: version "foo" is not yet installed.
|
||||
|
||||
You need to run `nvm install` to install and use the node version specified in `.nvmrc`.'
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "expected 'nvm_ensure_version_installed foo' to give $EXPECTED_OUTPUT, got $OUTPUT"
|
||||
[ "_$EXIT_CODE" = "_1" ] || die "expected 'nvm_ensure_version_installed foo' to exit with 1, got $EXIT_CODE"
|
||||
|
||||
@ -29,7 +38,7 @@ OUTPUT="$(nvm_ensure_version_installed iojs 2>&1)"
|
||||
EXIT_CODE=$?
|
||||
EXPECTED_OUTPUT='N/A: version "iojs" is not yet installed.
|
||||
|
||||
You need to run "nvm install iojs" to install it before using it.'
|
||||
You need to run `nvm install iojs` to install and use it.'
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "expected 'nvm_ensure_version_installed iojs' to give $EXPECTED_OUTPUT, got $OUTPUT"
|
||||
[ "_$EXIT_CODE" = "_1" ] || die "expected 'nvm_ensure_version_installed iojs' to exit with 1, got $EXIT_CODE"
|
||||
|
||||
|
50
test/installation_node/install on bash with ERR trap and set -E
Executable file
50
test/installation_node/install on bash with ERR trap and set -E
Executable file
@ -0,0 +1,50 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cleanup() {
|
||||
nvm cache clear
|
||||
nvm deactivate
|
||||
rm -rf "${NVM_DIR}"/v*
|
||||
nvm unalias default
|
||||
}
|
||||
|
||||
die() {
|
||||
echo "$@"
|
||||
cleanup || true
|
||||
exit 1
|
||||
}
|
||||
|
||||
\. ../../nvm.sh
|
||||
|
||||
if [ -z "${BASH-}" ]; then
|
||||
echo "This test only applies to Bash; skipping"
|
||||
exit
|
||||
fi
|
||||
|
||||
cleanup || true
|
||||
trap 'echo "==> EXIT signal received (status: $?)"; cleanup' EXIT
|
||||
|
||||
# shellcheck disable=SC3047
|
||||
trap 'echo "==> ERR signal received"; exit 1' ERR
|
||||
# shellcheck disable=SC3041
|
||||
set -E
|
||||
|
||||
# shellcheck disable=SC3045,SC3047
|
||||
ERR_TRAP_EXPECTED="$(trap -p ERR)"
|
||||
|
||||
# Adding ` || die 'install failed'` implicitly disables error handling and
|
||||
# prevents ERR trap execution, so for the purposes of this test, `nvm install`
|
||||
# can't be part of another command or statement
|
||||
nvm install node
|
||||
|
||||
case "$-" in
|
||||
*E*)
|
||||
# shellcheck disable=SC3045,SC3047
|
||||
[ "$(trap -p ERR)" = "$ERR_TRAP_EXPECTED" ] ||
|
||||
die "ERR trap not restored after \"nvm install $VERSION\""
|
||||
;;
|
||||
*)
|
||||
die "errtrace not restored after \"nvm install $VERSION\""
|
||||
;;
|
||||
esac
|
@ -7,10 +7,10 @@ die () { echo "$@" ; exit 1; }
|
||||
|
||||
EXPECTED_OUTPUT='N/A: version "v0.2" is not yet installed.
|
||||
|
||||
You need to run "nvm install 0.2" to install it before using it.'
|
||||
You need to run `nvm install 0.2` to install and use it.'
|
||||
[ "_$(nvm run 0.2 --version 2>&1)" = "_$EXPECTED_OUTPUT" ] || die "\`nvm run\` with an uninstalled node version failed to error out correctly"
|
||||
|
||||
EXPECTED_OUTPUT='N/A: version "iojs-v0.2" is not yet installed.
|
||||
|
||||
You need to run "nvm install iojs-0.2" to install it before using it.'
|
||||
You need to run `nvm install iojs-0.2` to install and use it.'
|
||||
[ "_$(nvm run iojs-0.2 --version 2>&1)" = "_$EXPECTED_OUTPUT" ] || die "\`nvm run\` with an uninstalled iojs version failed to error out correctly"
|
||||
|
@ -10,3 +10,16 @@ echo "0.10.7" > .nvmrc
|
||||
[ "$(nvm run --version | tail -1)" = "v0.10.7" ] || die "\`nvm run\` failed to run with the .nvmrc version"
|
||||
|
||||
[ "$(nvm run --version | head -1)" = "Found '$PWD/.nvmrc' with version <0.10.7>" ] || die "\`nvm run\` failed to print out the \"found in .nvmrc\" message"
|
||||
|
||||
|
||||
echo "foo" > .nvmrc
|
||||
|
||||
# running nvm run with .nvmrc should not print the version information when not installed
|
||||
OUTPUT="$(nvm run --version 2>&1)"
|
||||
EXIT_CODE=$?
|
||||
EXPECTED_OUTPUT="Found '$PWD/.nvmrc' with version <foo>
|
||||
N/A: version \"foo\" is not yet installed.
|
||||
|
||||
You need to run \`nvm install\` to install and use the node version specified in \`.nvmrc\`."
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "expected 'nvm use' with nvmrc to give $EXPECTED_OUTPUT, got $OUTPUT"
|
||||
[ "_$EXIT_CODE" = "_1" ] || die "expected 'nvm use' with nvmrc to exit with 1, got $EXIT_CODE"
|
||||
|
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
nvm deactivate 2>&1 >/dev/null || die 'deactivate failed'
|
||||
|
||||
echo "foo" > .nvmrc
|
||||
|
||||
# running nvm use with .nvmrc should not print the version information
|
||||
OUTPUT="$(nvm use 2>&1)"
|
||||
EXIT_CODE=$?
|
||||
EXPECTED_OUTPUT="Found '$PWD/.nvmrc' with version <foo>
|
||||
N/A: version \"foo\" is not yet installed.
|
||||
|
||||
You need to run \`nvm install\` to install and use the node version specified in \`.nvmrc\`."
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "expected 'nvm use' with nvmrc to give $EXPECTED_OUTPUT, got $OUTPUT"
|
||||
[ "_$EXIT_CODE" = "_3" ] || die "expected 'nvm use' with nvmrc to exit with 3, got $EXIT_CODE"
|
||||
|
||||
# --silent should not print anything
|
||||
OUTPUT=$(nvm use --silent)
|
||||
EXPECTED_OUTPUT=""
|
||||
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|
||||
|| die "'nvm use --silent' output was not silenced to '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||
|
||||
rm .nvmrc
|
@ -10,8 +10,8 @@ cleanup() {
|
||||
|
||||
EXPECTED_VERSION="v12.3.456"
|
||||
URL="https://github.com/nvm-sh/nvm/releases/tag/$EXPECTED_VERSION"
|
||||
EXPECTED_CURL_ARGS="--compressed -q -w %{url_effective}\n -L -s -S http://latest.nvm.sh -o /dev/null"
|
||||
EXPECTED_WGET_ARGS="-q http://latest.nvm.sh --server-response -O /dev/null"
|
||||
EXPECTED_CURL_ARGS="--compressed -q -w %{url_effective}\n -L -s -S https://latest.nvm.sh -o /dev/null"
|
||||
EXPECTED_WGET_ARGS="-q https://latest.nvm.sh --server-response -O /dev/null"
|
||||
|
||||
curl() {
|
||||
if [ $# -eq 1 ] && [ "$1" = "-V" ]; then
|
||||
|
@ -17,7 +17,7 @@ wget() {
|
||||
|
||||
OUTPUT="$(nvm_get_latest 2>&1)"
|
||||
EXIT_CODE="$(nvm_get_latest >/dev/null 2>&1 ; echo $?)"
|
||||
[ "_$OUTPUT" = "_http://latest.nvm.sh did not redirect to the latest release on GitHub" ] \
|
||||
[ "_$OUTPUT" = "_https://latest.nvm.sh did not redirect to the latest release on GitHub" ] \
|
||||
|| die "failed redirect did not report correct error message, got '$OUTPUT'"
|
||||
[ "_$EXIT_CODE" = "_2" ] \
|
||||
|| die "failed redirect did not exit with code 2, got $EXIT_CODE"
|
||||
|
Loading…
Reference in New Issue
Block a user