mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-05-17 09:31:51 +00:00
Compare commits
13 Commits
781cc6c30f
...
a285ffbe05
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a285ffbe05 | ||
![]() |
759f70f196 | ||
![]() |
06a9179309 | ||
![]() |
74eb396099 | ||
![]() |
9f520c97db | ||
![]() |
e5521cfd3c | ||
![]() |
247ed8a186 | ||
![]() |
14507f807f | ||
![]() |
6135555b40 | ||
![]() |
d90a7910db | ||
![]() |
8c30ac633b | ||
![]() |
ecdc865a5a | ||
![]() |
9bcbbef4eb |
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@ -19,6 +19,8 @@ jobs:
|
||||
raw.githubusercontent.com:443
|
||||
registry.npmjs.org:443
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-tags: true
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "14"
|
||||
|
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
@ -31,6 +31,8 @@ jobs:
|
||||
suite:
|
||||
- install_script
|
||||
- sourcing
|
||||
- slow
|
||||
- installation_iojs
|
||||
shell:
|
||||
- sh
|
||||
- bash
|
||||
|
10
.travis.yml
10
.travis.yml
@ -87,18 +87,8 @@ env:
|
||||
- SHELL=bash TEST_SUITE=fast
|
||||
- SHELL=zsh TEST_SUITE=fast
|
||||
# - SHELL=ksh TEST_SUITE=fast
|
||||
- SHELL=sh TEST_SUITE=slow
|
||||
- SHELL=dash TEST_SUITE=slow
|
||||
- SHELL=bash TEST_SUITE=slow
|
||||
- SHELL=zsh TEST_SUITE=slow
|
||||
# - SHELL=ksh TEST_SUITE=slow
|
||||
- SHELL=sh TEST_SUITE=installation_iojs
|
||||
- SHELL=sh TEST_SUITE=installation_iojs WITHOUT_CURL=1
|
||||
- SHELL=dash TEST_SUITE=installation_iojs
|
||||
- SHELL=dash TEST_SUITE=installation_iojs WITHOUT_CURL=1
|
||||
- SHELL=bash TEST_SUITE=installation_iojs
|
||||
- SHELL=bash TEST_SUITE=installation_iojs WITHOUT_CURL=1
|
||||
- SHELL=zsh TEST_SUITE=installation_iojs
|
||||
- SHELL=zsh TEST_SUITE=installation_iojs WITHOUT_CURL=1
|
||||
# - SHELL=ksh TEST_SUITE=installation_iojs
|
||||
# - SHELL=ksh TEST_SUITE=installation_iojs WITHOUT_CURL=1
|
||||
|
18
README.md
18
README.md
@ -109,7 +109,7 @@ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
|
||||
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.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`).
|
||||
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 (`~/.bashrc`, `~/.bash_profile`, `~/.zshrc`, or `~/.profile`). If you find the install script is updating the wrong profile file, set the `$PROFILE` env var to the profile file’s path, and then rerun the installation script.
|
||||
|
||||
<a id="profile_snippet"></a>
|
||||
```sh
|
||||
@ -121,7 +121,12 @@ export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || pr
|
||||
|
||||
- If the environment variable `$XDG_CONFIG_HOME` is present, it will place the `nvm` files there.</sub>
|
||||
|
||||
- You can add `--no-use` to the end of the above script (...`nvm.sh --no-use`) to postpone using `nvm` until you manually [`use`](#usage) it.
|
||||
- You can add `--no-use` to the end of the above script to postpone using `nvm` until you manually [`use`](#usage) it:
|
||||
|
||||
```sh
|
||||
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" --no-use # This loads nvm, without auto-using the default version
|
||||
```
|
||||
|
||||
- You can customize the install source, directory, profile, and version using the `NVM_SOURCE`, `NVM_DIR`, `PROFILE`, and `NODE_VERSION` variables.
|
||||
Eg: `curl ... | NVM_DIR="path/to/nvm"`. Ensure that the `NVM_DIR` does not contain a trailing slash.
|
||||
@ -247,7 +252,7 @@ If you're running a system without prepackaged binary available, which means you
|
||||
|
||||
Homebrew installation is not supported. If you have issues with homebrew-installed `nvm`, please `brew uninstall` it, and install it using the instructions below, before filing an issue.
|
||||
|
||||
**Note:** If you're using `zsh` you can easily install `nvm` as a zsh plugin. Install [`zsh-nvm`](https://github.com/lukechilds/zsh-nvm) and run `nvm upgrade` to upgrade.
|
||||
**Note:** If you're using `zsh` you can easily install `nvm` as a zsh plugin. Install [`zsh-nvm`](https://github.com/lukechilds/zsh-nvm) and run `nvm upgrade` to upgrade ([you can set](https://github.com/lukechilds/zsh-nvm#auto-use) `NVM_AUTO_USE=true` to have it automatically detect and use `.nvmrc` files).
|
||||
|
||||
**Note:** Git versions before v1.7 may face a problem of cloning `nvm` source from GitHub via https protocol, and there is also different behavior of git before v1.6, and git prior to [v1.17.10](https://github.com/git/git/commit/5a7d5b683f869d3e3884a89775241afa515da9e7) can not clone tags, so the minimum required git version is v1.7.10. If you are interested in the problem we mentioned here, please refer to GitHub's [HTTPS cloning errors](https://help.github.com/articles/https-cloning-errors/) article.
|
||||
|
||||
@ -703,6 +708,8 @@ add-zsh-hook chpwd load-nvmrc
|
||||
load-nvmrc
|
||||
```
|
||||
|
||||
After saving the file, run `source ~/.zshrc` to reload the configuration with the latest changes made.
|
||||
|
||||
##### fish
|
||||
|
||||
This requires that you have [bass](https://github.com/edc/bass) installed.
|
||||
@ -1106,6 +1113,5 @@ See [LICENSE.md](./LICENSE.md).
|
||||
|
||||
## Copyright notice
|
||||
|
||||
Copyright [OpenJS Foundation](https://openjsf.org) and `nvm` contributors. All rights reserved. The [OpenJS Foundation](https://openjsf.org) has registered trademarks and uses trademarks. For a list of trademarks of the [OpenJS Foundation](https://openjsf.org), please see our [Trademark Policy](https://trademark-policy.openjsf.org/) and [Trademark List](https://trademark-list.openjsf.org/). Node.js is a trademark of Joyent, Inc. and is used with its permission. Trademarks and logos not indicated on the [list of OpenJS Foundation trademarks](https://trademark-list.openjsf.org) are trademarks™ or registered® trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them.
|
||||
|
||||
[The OpenJS Foundation](https://openjsf.org/) | [Terms of Use](https://terms-of-use.openjsf.org/) | [Privacy Policy](https://privacy-policy.openjsf.org/) | [OpenJS Foundation Bylaws](https://bylaws.openjsf.org/) | [Trademark Policy](https://trademark-policy.openjsf.org/) | [Trademark List](https://trademark-list.openjsf.org/) | [Cookie Policy](https://www.linuxfoundation.org/cookies/)
|
||||
Copyright [OpenJS Foundation](https://openjsf.org) and `nvm` contributors. All rights reserved. The [OpenJS Foundation](https://openjsf.org) has registered trademarks and uses trademarks. For a list of trademarks of the [OpenJS Foundation](https://openjsf.org), please see our [Trademark Policy](https://trademark-policy.openjsf.org/) and [Trademark List](https://trademark-list.openjsf.org/). Trademarks and logos not indicated on the [list of OpenJS Foundation trademarks](https://trademark-list.openjsf.org) are trademarks™ or registered® trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them.
|
||||
[The OpenJS Foundation](https://openjsf.org/) | [Terms of Use](https://terms-of-use.openjsf.org/) | [Privacy Policy](https://privacy-policy.openjsf.org/) | [Bylaws](https://bylaws.openjsf.org/) | [Code of Conduct](https://code-of-conduct.openjsf.org) | [Trademark Policy](https://trademark-policy.openjsf.org/) | [Trademark List](https://trademark-list.openjsf.org/) | [Cookie Policy](https://www.linuxfoundation.org/cookies/)
|
||||
|
47
nvm.sh
47
nvm.sh
@ -136,15 +136,17 @@ nvm_download() {
|
||||
eval "curl -q --fail ${CURL_COMPRESSED_FLAG:-} ${CURL_HEADER_FLAG:-} ${NVM_DOWNLOAD_ARGS}"
|
||||
elif nvm_has "wget"; then
|
||||
# Emulate curl with wget
|
||||
ARGS=$(nvm_echo "$@" | command sed -e 's/--progress-bar /--progress=bar /' \
|
||||
-e 's/--compressed //' \
|
||||
-e 's/--fail //' \
|
||||
-e 's/-L //' \
|
||||
-e 's/-I /--server-response /' \
|
||||
-e 's/-s /-q /' \
|
||||
-e 's/-sS /-nv /' \
|
||||
-e 's/-o /-O /' \
|
||||
-e 's/-C - /-c /')
|
||||
ARGS=$(nvm_echo "$@" | command sed "
|
||||
s/--progress-bar /--progress=bar /
|
||||
s/--compressed //
|
||||
s/--fail //
|
||||
s/-L //
|
||||
s/-I /--server-response /
|
||||
s/-s /-q /
|
||||
s/-sS /-nv /
|
||||
s/-o /-O /
|
||||
s/-C - /-c /
|
||||
")
|
||||
|
||||
if [ -n "${NVM_AUTH_HEADER:-}" ]; then
|
||||
ARGS="${ARGS} --header \"${NVM_AUTH_HEADER}\""
|
||||
@ -1436,11 +1438,11 @@ nvm_add_iojs_prefix() {
|
||||
nvm_strip_iojs_prefix() {
|
||||
local NVM_IOJS_PREFIX
|
||||
NVM_IOJS_PREFIX="$(nvm_iojs_prefix)"
|
||||
if [ "${1-}" = "${NVM_IOJS_PREFIX}" ]; then
|
||||
nvm_echo
|
||||
else
|
||||
nvm_echo "${1#"${NVM_IOJS_PREFIX}"-}"
|
||||
fi
|
||||
|
||||
case "${1-}" in
|
||||
"${NVM_IOJS_PREFIX}") nvm_echo ;;
|
||||
*) nvm_echo "${1#"${NVM_IOJS_PREFIX}"-}" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
nvm_ls() {
|
||||
@ -1572,12 +1574,15 @@ nvm_ls() {
|
||||
fi
|
||||
|
||||
if [ "${NVM_ADD_SYSTEM-}" = true ]; then
|
||||
if [ -z "${PATTERN}" ] || [ "${PATTERN}" = 'v' ]; then
|
||||
VERSIONS="${VERSIONS}
|
||||
case "${PATTERN}" in
|
||||
'' | v)
|
||||
VERSIONS="${VERSIONS}
|
||||
system"
|
||||
elif [ "${PATTERN}" = 'system' ]; then
|
||||
VERSIONS="system"
|
||||
fi
|
||||
;;
|
||||
system)
|
||||
VERSIONS="system"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [ -z "${VERSIONS}" ]; then
|
||||
@ -1711,7 +1716,7 @@ EOF
|
||||
LTS="${LTS#lts/}"
|
||||
fi
|
||||
|
||||
VERSIONS="$({ command awk -v lts="${LTS-}" '{
|
||||
VERSIONS="$( { command awk -v lts="${LTS-}" '{
|
||||
if (!$1) { next }
|
||||
if (lts && $10 ~ /^\-?$/) { next }
|
||||
if (lts && lts != "*" && tolower($10) !~ tolower(lts)) { next }
|
||||
@ -2755,7 +2760,7 @@ nvm_npm_global_modules() {
|
||||
local NPMLIST
|
||||
local VERSION
|
||||
VERSION="$1"
|
||||
NPMLIST=$(nvm use "${VERSION}" >/dev/null && npm list -g --depth=0 2>/dev/null | command sed 1,1d | nvm_grep -v 'UNMET PEER DEPENDENCY')
|
||||
NPMLIST=$(nvm use "${VERSION}" >/dev/null && npm list -g --depth=0 2>/dev/null | command sed -e '1d' -e '/UNMET PEER DEPENDENCY/d')
|
||||
|
||||
local INSTALLS
|
||||
INSTALLS=$(nvm_echo "${NPMLIST}" | command sed -e '/ -> / d' -e '/\(empty\)/ d' -e 's/^.* \(.*@[^ ]*\).*/\1/' -e '/^npm@[^ ]*.*$/ d' | command xargs)
|
||||
|
@ -45,7 +45,7 @@
|
||||
"dockerfile_lint": "^0.3.4",
|
||||
"doctoc": "^2.2.1",
|
||||
"eclint": "^2.8.1",
|
||||
"markdown-link-check": "^3.12.2",
|
||||
"markdown-link-check": "^3.13.6",
|
||||
"replace": "^1.2.2",
|
||||
"semver": "^7.6.3",
|
||||
"urchin": "^0.0.5"
|
||||
|
28
test/slow/nvm run/Running 'nvm run --silent' should work
Executable file
28
test/slow/nvm run/Running 'nvm run --silent' should work
Executable file
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
echo "0.10.7" > .nvmrc
|
||||
|
||||
# Check nvm run without --silent
|
||||
OUTPUT="$(nvm run --version)"
|
||||
EXPECTED_OUTPUT="Found '${PWD}/.nvmrc' with version <0.10.7>
|
||||
Running node v0.10.7 (npm v1.2.21)
|
||||
v0.10.7"
|
||||
[ ">${OUTPUT}<" = ">${EXPECTED_OUTPUT}<" ] \
|
||||
|| die "\`nvm run\` failed to run; did not match with the .nvmrc version; got >${OUTPUT}<"
|
||||
|
||||
OUTPUT="$(nvm run --silent --version)"
|
||||
EXPECTED_OUTPUT="v0.10.7"
|
||||
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] \
|
||||
|| die "\`nvm run --silent\` failed to run silently; expected no output, got >${OUTPUT}<"
|
||||
|
||||
# Output shouldn't be silent if --silent flag is not at the third argument position
|
||||
OUTPUT="$(nvm run --version --silent)"
|
||||
EXPECTED_OUTPUT=""
|
||||
[ "${OUTPUT}" != "${EXPECTED_OUTPUT}" ] \
|
||||
|| die "\`nvm run --version --silent\` should not be silent; expected >${OUTPUT}<, got no output"
|
Loading…
Reference in New Issue
Block a user