mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-12-12 08:04:18 +00:00
Compare commits
14 Commits
a3cac806be
...
tmp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d4cc592ff1 | ||
|
|
c8b55175dc | ||
|
|
db0b085965 | ||
|
|
206302caad | ||
|
|
42a5175402 | ||
|
|
02795cd71d | ||
|
|
0641363102 | ||
|
|
9659af6c16 | ||
|
|
abd02e5aae | ||
|
|
3de0b15810 | ||
|
|
cd22c84026 | ||
|
|
d648a3b1ba | ||
|
|
ccf6d16017 | ||
|
|
ba98270442 |
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
blank_issues_enabled: false
|
||||||
@@ -1,3 +1,11 @@
|
|||||||
|
---
|
||||||
|
name: File an issue…
|
||||||
|
about: Create a report to help us improve
|
||||||
|
title: ''
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
<!-- Thank you for being interested in nvm! Please help us by filling out the following form if you‘re having trouble. If you have a feature request, or some other question, please feel free to clear out the form. Thanks! -->
|
<!-- Thank you for being interested in nvm! Please help us by filling out the following form if you‘re having trouble. If you have a feature request, or some other question, please feel free to clear out the form. Thanks! -->
|
||||||
|
|
||||||
5
.github/workflows/latest-npm.yml
vendored
5
.github/workflows/latest-npm.yml
vendored
@@ -37,6 +37,11 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
node-version: ${{ fromJson(needs.matrix.outputs.latest) }}
|
node-version: ${{ fromJson(needs.matrix.outputs.latest) }}
|
||||||
include:
|
include:
|
||||||
|
- node-version: "21"
|
||||||
|
- node-version: "20.5"
|
||||||
|
- node-version: "20.4"
|
||||||
|
- node-version: "14.17"
|
||||||
|
- node-version: "14.16"
|
||||||
- node-version: "9.2"
|
- node-version: "9.2"
|
||||||
- node-version: "9.1"
|
- node-version: "9.1"
|
||||||
- node-version: "9.0"
|
- node-version: "9.0"
|
||||||
|
|||||||
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
@@ -1,6 +1,6 @@
|
|||||||
name: urchin tests
|
name: urchin tests
|
||||||
|
|
||||||
on: [push]
|
on: [push, pull_request]
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|||||||
3
.github/workflows/toc.yml
vendored
3
.github/workflows/toc.yml
vendored
@@ -20,6 +20,7 @@ jobs:
|
|||||||
allowed-endpoints:
|
allowed-endpoints:
|
||||||
github.com:443
|
github.com:443
|
||||||
registry.npmjs.org:443
|
registry.npmjs.org:443
|
||||||
|
api.github.com:443
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
# https://github.com/actions/checkout/issues/217#issue-599945005
|
# https://github.com/actions/checkout/issues/217#issue-599945005
|
||||||
@@ -30,7 +31,7 @@ jobs:
|
|||||||
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
|
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '16'
|
node-version: 'lts/*'
|
||||||
- run: npm install
|
- run: npm install
|
||||||
- run: npm run doctoc
|
- run: npm run doctoc
|
||||||
- name: commit changes
|
- name: commit changes
|
||||||
|
|||||||
@@ -113,3 +113,11 @@ Co-authored-by: Name Here <email@here>
|
|||||||
|
|
||||||
# Where can I ask for help?
|
# Where can I ask for help?
|
||||||
If you have any questions, please contact [@LJHarb](mailto:ljharb@gmail.com).
|
If you have any questions, please contact [@LJHarb](mailto:ljharb@gmail.com).
|
||||||
|
|
||||||
|
# Developer's Certificate of Origin 1.1
|
||||||
|
|
||||||
|
By making a contribution to this project, I certify that:
|
||||||
|
- The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or
|
||||||
|
- The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or
|
||||||
|
- The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it.
|
||||||
|
- I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved.
|
||||||
|
|||||||
10
install.sh
10
install.sh
@@ -296,17 +296,17 @@ nvm_detect_profile() {
|
|||||||
DETECTED_PROFILE="$HOME/.bash_profile"
|
DETECTED_PROFILE="$HOME/.bash_profile"
|
||||||
fi
|
fi
|
||||||
elif [ "${SHELL#*zsh}" != "$SHELL" ]; then
|
elif [ "${SHELL#*zsh}" != "$SHELL" ]; then
|
||||||
if [ -f "$HOME/.zshrc" ]; then
|
if [ -f "${ZDOTDIR:-${HOME}}/.zshrc" ]; then
|
||||||
DETECTED_PROFILE="$HOME/.zshrc"
|
DETECTED_PROFILE="${ZDOTDIR:-${HOME}}/.zshrc"
|
||||||
elif [ -f "$HOME/.zprofile" ]; then
|
elif [ -f "${ZDOTDIR:-${HOME}}/.zprofile" ]; then
|
||||||
DETECTED_PROFILE="$HOME/.zprofile"
|
DETECTED_PROFILE="${ZDOTDIR:-${HOME}}/.zprofile"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$DETECTED_PROFILE" ]; then
|
if [ -z "$DETECTED_PROFILE" ]; then
|
||||||
for EACH_PROFILE in ".profile" ".bashrc" ".bash_profile" ".zprofile" ".zshrc"
|
for EACH_PROFILE in ".profile" ".bashrc" ".bash_profile" ".zprofile" ".zshrc"
|
||||||
do
|
do
|
||||||
if DETECTED_PROFILE="$(nvm_try_profile "${HOME}/${EACH_PROFILE}")"; then
|
if DETECTED_PROFILE="$(nvm_try_profile "${ZDOTDIR:-${HOME}}/${EACH_PROFILE}")"; then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
61
nvm.sh
61
nvm.sh
@@ -354,6 +354,21 @@ nvm_install_latest_npm() {
|
|||||||
if [ $NVM_IS_19_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 20.5.0; then
|
if [ $NVM_IS_19_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 20.5.0; then
|
||||||
NVM_IS_20_5_OR_ABOVE=1
|
NVM_IS_20_5_OR_ABOVE=1
|
||||||
fi
|
fi
|
||||||
|
local NVM_IS_20_17_or_ABOVE
|
||||||
|
NVM_IS_20_17_or_ABOVE=0
|
||||||
|
if [ $NVM_IS_20_5_OR_ABOVE -eq 1 ] && nvm_version_greater 20.17.0 "${NODE_VERSION}"; then
|
||||||
|
NVM_IS_20_17_or_ABOVE=1
|
||||||
|
fi
|
||||||
|
local NVM_IS_21_OR_ABOVE
|
||||||
|
NVM_IS_21_OR_ABOVE=0
|
||||||
|
if [ $NVM_IS_20_17_or_ABOVE -eq 1 ] && nvm_version_greater 21.0.0 "${NODE_VERSION}"; then
|
||||||
|
NVM_IS_21_OR_ABOVE=1
|
||||||
|
fi
|
||||||
|
local NVM_IS_22_9_OR_ABOVE
|
||||||
|
NVM_IS_22_9_OR_ABOVE=0
|
||||||
|
if [ $NVM_IS_21_OR_ABOVE -eq 1 ] && nvm_version_greater 22.9.0 "${NODE_VERSION}"; then
|
||||||
|
NVM_IS_22_9_OR_ABOVE=1
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $NVM_IS_4_4_OR_BELOW -eq 1 ] || {
|
if [ $NVM_IS_4_4_OR_BELOW -eq 1 ] || {
|
||||||
[ $NVM_IS_5_OR_ABOVE -eq 1 ] && nvm_version_greater 5.10.0 "${NODE_VERSION}"; \
|
[ $NVM_IS_5_OR_ABOVE -eq 1 ] && nvm_version_greater 5.10.0 "${NODE_VERSION}"; \
|
||||||
@@ -399,8 +414,15 @@ nvm_install_latest_npm() {
|
|||||||
[ $NVM_IS_18_17_OR_ABOVE -eq 0 ] \
|
[ $NVM_IS_18_17_OR_ABOVE -eq 0 ] \
|
||||||
|| { [ $NVM_IS_19_OR_ABOVE -eq 1 ] && [ $NVM_IS_20_5_OR_ABOVE -eq 0 ]; } \
|
|| { [ $NVM_IS_19_OR_ABOVE -eq 1 ] && [ $NVM_IS_20_5_OR_ABOVE -eq 0 ]; } \
|
||||||
; then
|
; then
|
||||||
|
# TODO: 10.8.3 can run on 16.20.2?? https://github.com/nodejs/Release/issues/884#issuecomment-2558077691
|
||||||
nvm_echo '* `npm` `v9.x` is the last version that works on `node` `< v18.17`, `v19`, or `v20.0` - `v20.4`'
|
nvm_echo '* `npm` `v9.x` is the last version that works on `node` `< v18.17`, `v19`, or `v20.0` - `v20.4`'
|
||||||
$NVM_NPM_CMD install -g npm@9
|
$NVM_NPM_CMD install -g npm@9
|
||||||
|
elif \
|
||||||
|
[ $NVM_IS_20_17_or_ABOVE -eq 0 ] \
|
||||||
|
|| { [ $NVM_IS_21_OR_ABOVE -eq 1 ] && [ $NVM_IS_22_9_OR_ABOVE -eq 0 ]; } \
|
||||||
|
; then
|
||||||
|
nvm_echo '* `npm` `v10.x` is the last version that works on `node` `< v20.17`, `v21`, or `v22.0` - `v22.8`'
|
||||||
|
$NVM_NPM_CMD install -g npm@10
|
||||||
else
|
else
|
||||||
nvm_echo '* Installing latest `npm`; if this does not work on your node version, please report a bug!'
|
nvm_echo '* Installing latest `npm`; if this does not work on your node version, please report a bug!'
|
||||||
$NVM_NPM_CMD install -g npm
|
$NVM_NPM_CMD install -g npm
|
||||||
@@ -422,8 +444,7 @@ fi
|
|||||||
if [ -z "${NVM_DIR-}" ]; then
|
if [ -z "${NVM_DIR-}" ]; then
|
||||||
# shellcheck disable=SC2128
|
# shellcheck disable=SC2128
|
||||||
if [ -n "${BASH_SOURCE-}" ]; then
|
if [ -n "${BASH_SOURCE-}" ]; then
|
||||||
# shellcheck disable=SC2169,SC3054
|
NVM_SCRIPT_SOURCE="${BASH_SOURCE}"
|
||||||
NVM_SCRIPT_SOURCE="${BASH_SOURCE[0]}"
|
|
||||||
fi
|
fi
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
NVM_DIR="$(nvm_cd ${NVM_CD_FLAGS} "$(dirname "${NVM_SCRIPT_SOURCE:-$0}")" >/dev/null && \pwd)"
|
NVM_DIR="$(nvm_cd ${NVM_CD_FLAGS} "$(dirname "${NVM_SCRIPT_SOURCE:-$0}")" >/dev/null && \pwd)"
|
||||||
@@ -1857,15 +1878,12 @@ nvm_print_versions() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
command awk \
|
command awk \
|
||||||
-v remote_versions="$(printf '%s' "${1-}" | tr '\n' '|')" -v min="${NVM_MIN:-v0}" \
|
-v remote_versions="$(printf '%s' "${1-}" | tr '\n' '|')" \
|
||||||
-v installed_versions="$(nvm_ls | tr '\n' '|')" -v current="$NVM_CURRENT" \
|
-v installed_versions="$(nvm_ls | tr '\n' '|')" -v current="$NVM_CURRENT" \
|
||||||
-v installed_color="$INSTALLED_COLOR" -v system_color="$SYSTEM_COLOR" \
|
-v installed_color="$INSTALLED_COLOR" -v system_color="$SYSTEM_COLOR" \
|
||||||
-v current_color="$CURRENT_COLOR" -v default_color="$DEFAULT_COLOR" \
|
-v current_color="$CURRENT_COLOR" -v default_color="$DEFAULT_COLOR" \
|
||||||
-v old_lts_color="$DEFAULT_COLOR" -v has_colors="$NVM_HAS_COLORS" '
|
-v old_lts_color="$DEFAULT_COLOR" -v has_colors="$NVM_HAS_COLORS" '
|
||||||
function alen(arr, i, len) { len=0; for(i in arr) len++; return len; }
|
function alen(arr, i, len) { len=0; for(i in arr) len++; return len; }
|
||||||
function v2a(v, a) { sub(/^(iojs-)?v/, "", v); split(v, a, "."); }
|
|
||||||
function v2m(v, a) { sub(/^(iojs-)?v/, "", v); split(v, a, "."); return a[1]; }
|
|
||||||
function vcmp(v1,v2,a1,a2,i,d) { v2a(v1,a1); v2a(v2,a2); for(i=1;i<4;i++) { d = a1[i] - a2[i]; if(d!=0) return d; } return 0; }
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
fmt_installed = has_colors ? (installed_color ? "\033[" installed_color "%15s\033[0m" : "%15s") : "%15s *";
|
fmt_installed = has_colors ? (installed_color ? "\033[" installed_color "%15s\033[0m" : "%15s") : "%15s *";
|
||||||
fmt_system = has_colors ? (system_color ? "\033[" system_color "%15s\033[0m" : "%15s") : "%15s *";
|
fmt_system = has_colors ? (system_color ? "\033[" system_color "%15s\033[0m" : "%15s") : "%15s *";
|
||||||
@@ -1880,13 +1898,13 @@ BEGIN {
|
|||||||
split(remote_versions, lines, "|");
|
split(remote_versions, lines, "|");
|
||||||
split(installed_versions, installed, "|");
|
split(installed_versions, installed, "|");
|
||||||
rows = alen(lines);
|
rows = alen(lines);
|
||||||
filter_on = (vcmp("v0.0.0", min) != 0);
|
|
||||||
current_major = -1;
|
for (n = 1; n <= rows; n++) {
|
||||||
for (m = n = 1; n <= rows; n++) {
|
|
||||||
split(lines[n], fields, "[[:blank:]]+");
|
split(lines[n], fields, "[[:blank:]]+");
|
||||||
cols = alen(fields);
|
cols = alen(fields);
|
||||||
version = fields[1];
|
version = fields[1];
|
||||||
is_installed = 0;
|
is_installed = 0;
|
||||||
|
|
||||||
for (i in installed) {
|
for (i in installed) {
|
||||||
if (version == installed[i]) {
|
if (version == installed[i]) {
|
||||||
is_installed = 1;
|
is_installed = 1;
|
||||||
@@ -1894,16 +1912,6 @@ BEGIN {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter_on != 0) {
|
|
||||||
if (is_installed) {
|
|
||||||
current_major = v2m(version);
|
|
||||||
} else if (vcmp(version, min) >= 0) {
|
|
||||||
filter_on = 0;
|
|
||||||
} else if (v2m(version) != current_major) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt_version = "%15s";
|
fmt_version = "%15s";
|
||||||
if (version == current) {
|
if (version == current) {
|
||||||
fmt_version = fmt_current;
|
fmt_version = fmt_current;
|
||||||
@@ -1913,7 +1921,8 @@ BEGIN {
|
|||||||
fmt_version = fmt_installed;
|
fmt_version = fmt_installed;
|
||||||
}
|
}
|
||||||
|
|
||||||
padding = (is_installed && !has_colors) ? "" : " ";
|
padding = (!has_colors && is_installed) ? "" : " ";
|
||||||
|
|
||||||
if (cols == 1) {
|
if (cols == 1) {
|
||||||
formatted = sprintf(fmt_version, version);
|
formatted = sprintf(fmt_version, version);
|
||||||
} else if (cols == 2) {
|
} else if (cols == 2) {
|
||||||
@@ -1922,10 +1931,10 @@ BEGIN {
|
|||||||
formatted = sprintf((fmt_version padding fmt_latest_lts), version, fields[2]);
|
formatted = sprintf((fmt_version padding fmt_latest_lts), version, fields[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
output[m++] = formatted;
|
output[n] = formatted;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (n = 1; n < m; n++) {
|
for (n = 1; n <= rows; n++) {
|
||||||
print output[n]
|
print output[n]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3092,7 +3101,6 @@ nvm() {
|
|||||||
nvm_echo ' nvm ls-remote [<version>] List remote versions available for install, matching a given <version> if provided'
|
nvm_echo ' nvm ls-remote [<version>] List remote versions available for install, matching a given <version> if provided'
|
||||||
nvm_echo ' --lts When listing, only show LTS (long-term support) versions'
|
nvm_echo ' --lts When listing, only show LTS (long-term support) versions'
|
||||||
nvm_echo ' --lts=<LTS name> When listing, only show versions for a specific LTS line'
|
nvm_echo ' --lts=<LTS name> When listing, only show versions for a specific LTS line'
|
||||||
nvm_echo ' --min=<version> When listing, only show versions greater than or equal to <version>, including minor/patch updates for installed versions'
|
|
||||||
nvm_echo ' --no-colors Suppress colored output'
|
nvm_echo ' --no-colors Suppress colored output'
|
||||||
nvm_echo ' nvm version <version> Resolve the given description to a single local version'
|
nvm_echo ' nvm version <version> Resolve the given description to a single local version'
|
||||||
nvm_echo ' nvm version-remote <version> Resolve the given description to a single remote version'
|
nvm_echo ' nvm version-remote <version> Resolve the given description to a single remote version'
|
||||||
@@ -4111,10 +4119,6 @@ nvm() {
|
|||||||
local NVM_LTS
|
local NVM_LTS
|
||||||
local PATTERN
|
local PATTERN
|
||||||
local NVM_NO_COLORS
|
local NVM_NO_COLORS
|
||||||
local NVM_MIN_ENV
|
|
||||||
NVM_MIN_ENV="${NVM_MIN-}"
|
|
||||||
local NVM_MIN
|
|
||||||
NVM_MIN="${NVM_MIN_ENV-}"
|
|
||||||
|
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case "${1-}" in
|
case "${1-}" in
|
||||||
@@ -4125,9 +4129,6 @@ nvm() {
|
|||||||
--lts=*)
|
--lts=*)
|
||||||
NVM_LTS="${1##--lts=}"
|
NVM_LTS="${1##--lts=}"
|
||||||
;;
|
;;
|
||||||
--min=*)
|
|
||||||
NVM_MIN="${1##--min=}"
|
|
||||||
;;
|
|
||||||
--no-colors) NVM_NO_COLORS="${1}" ;;
|
--no-colors) NVM_NO_COLORS="${1}" ;;
|
||||||
--*)
|
--*)
|
||||||
nvm_err "Unsupported option \"${1}\"."
|
nvm_err "Unsupported option \"${1}\"."
|
||||||
|
|||||||
@@ -1,146 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# shellcheck disable=SC2317
|
|
||||||
|
|
||||||
die () { echo "$@" ; cleanup ; exit 1; }
|
|
||||||
|
|
||||||
cleanup() {
|
|
||||||
unset -f nvm_remote_versions nvm_ls nvm_ls_current
|
|
||||||
if [ -n "$TEMP_NVM_MIN" ]; then
|
|
||||||
export NVM_MIN="$TEMP_NVM_MIN"
|
|
||||||
unset TEMP_NVM_MIN
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
\. ../../../nvm.sh
|
|
||||||
|
|
||||||
|
|
||||||
if [ -n "$NVM_MIN" ]; then
|
|
||||||
TEMP_NVM_MIN="$NVM_MIN"
|
|
||||||
unset NVM_MIN
|
|
||||||
fi
|
|
||||||
|
|
||||||
# mock currently installed versions
|
|
||||||
nvm_ls() {
|
|
||||||
echo "v16.20.2
|
|
||||||
v18.20.3
|
|
||||||
system"
|
|
||||||
}
|
|
||||||
|
|
||||||
# mock currently active version
|
|
||||||
nvm_ls_current() {
|
|
||||||
echo "v18.20.3"
|
|
||||||
}
|
|
||||||
|
|
||||||
nvm_remote_versions() {
|
|
||||||
echo "v16.0.0
|
|
||||||
v16.20.2 Gallium
|
|
||||||
v16.20.3 Gallium *
|
|
||||||
v17.0.0
|
|
||||||
v17.9.1
|
|
||||||
v18.0.0
|
|
||||||
v18.1.0
|
|
||||||
v18.20.2 Hydrogen
|
|
||||||
v18.20.3 Hydrogen *
|
|
||||||
v19.0.0
|
|
||||||
v19.9.0
|
|
||||||
v20.0.0
|
|
||||||
v20.8.1
|
|
||||||
v20.9.0 Iron *
|
|
||||||
v21.0.0
|
|
||||||
v21.1.0"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# nvm_print_versions should print all versions from nvm_remote_versions
|
|
||||||
OUTPUT="$(NVM_NO_COLORS='--no-colors' nvm_print_versions "$(nvm_remote_versions)" | sed -r 's/^[ \t]+//')"
|
|
||||||
EXPECTED_OUTPUT="v16.0.0
|
|
||||||
v16.20.2 * (LTS: Gallium)
|
|
||||||
v16.20.3 (Latest LTS: Gallium)
|
|
||||||
v17.0.0
|
|
||||||
v17.9.1
|
|
||||||
v18.0.0
|
|
||||||
v18.1.0
|
|
||||||
v18.20.2 (LTS: Hydrogen)
|
|
||||||
-> v18.20.3 * (Latest LTS: Hydrogen)
|
|
||||||
v19.0.0
|
|
||||||
v19.9.0
|
|
||||||
v20.0.0
|
|
||||||
v20.8.1
|
|
||||||
v20.9.0 (Latest LTS: Iron)
|
|
||||||
v21.0.0
|
|
||||||
v21.1.0"
|
|
||||||
|
|
||||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "(1) nvm_print_versions did not output all expected versions; got $OUTPUT"
|
|
||||||
|
|
||||||
|
|
||||||
# versions lower than 18 should be filtered out, but v16.20.2 should be kept since it's installed
|
|
||||||
OUTPUT="$(NVM_NO_COLORS='--no-colors' NVM_MIN=v18 nvm_print_versions "$(nvm_remote_versions)" | sed -r 's/^[ \t]+//')"
|
|
||||||
EXPECTED_OUTPUT="v16.20.2 * (LTS: Gallium)
|
|
||||||
v16.20.3 (Latest LTS: Gallium)
|
|
||||||
v18.0.0
|
|
||||||
v18.1.0
|
|
||||||
v18.20.2 (LTS: Hydrogen)
|
|
||||||
-> v18.20.3 * (Latest LTS: Hydrogen)
|
|
||||||
v19.0.0
|
|
||||||
v19.9.0
|
|
||||||
v20.0.0
|
|
||||||
v20.8.1
|
|
||||||
v20.9.0 (Latest LTS: Iron)
|
|
||||||
v21.0.0
|
|
||||||
v21.1.0"
|
|
||||||
|
|
||||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "(2) NVM_MIN=18 nvm_print_versions did not output all expected versions; got $OUTPUT"
|
|
||||||
|
|
||||||
|
|
||||||
# versions lower than 19 should be filtered out
|
|
||||||
OUTPUT="$(NVM_NO_COLORS='--no-colors' NVM_MIN=19 nvm_print_versions "$(nvm_remote_versions)" | sed -r 's/^[ \t]+//')"
|
|
||||||
EXPECTED_OUTPUT="v16.20.2 * (LTS: Gallium)
|
|
||||||
v16.20.3 (Latest LTS: Gallium)
|
|
||||||
-> v18.20.3 * (Latest LTS: Hydrogen)
|
|
||||||
v19.0.0
|
|
||||||
v19.9.0
|
|
||||||
v20.0.0
|
|
||||||
v20.8.1
|
|
||||||
v20.9.0 (Latest LTS: Iron)
|
|
||||||
v21.0.0
|
|
||||||
v21.1.0"
|
|
||||||
|
|
||||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "(3) NVM_MIN=19 nvm_print_versions did not output all expected versions; got $OUTPUT"
|
|
||||||
|
|
||||||
|
|
||||||
# versions lower than 20.1 should be filtered out, so v20.0.0 is out
|
|
||||||
OUTPUT="$(NVM_NO_COLORS='--no-colors' NVM_MIN=v20.1 nvm_print_versions "$(nvm_remote_versions)" | sed -r 's/^[ \t]+//')"
|
|
||||||
EXPECTED_OUTPUT="v16.20.2 * (LTS: Gallium)
|
|
||||||
v16.20.3 (Latest LTS: Gallium)
|
|
||||||
-> v18.20.3 * (Latest LTS: Hydrogen)
|
|
||||||
v20.8.1
|
|
||||||
v20.9.0 (Latest LTS: Iron)
|
|
||||||
v21.0.0
|
|
||||||
v21.1.0"
|
|
||||||
|
|
||||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "(4) NVM_MIN=20.1 nvm_print_versions did not output all expected versions; got $OUTPUT"
|
|
||||||
|
|
||||||
|
|
||||||
# assume v18.20.3 is NOT installed, so now it should be filtered out
|
|
||||||
nvm_ls() {
|
|
||||||
echo "v16.20.2
|
|
||||||
system"
|
|
||||||
}
|
|
||||||
|
|
||||||
nvm_ls_current() {
|
|
||||||
echo "v16.20.2"
|
|
||||||
}
|
|
||||||
|
|
||||||
OUTPUT="$(NVM_NO_COLORS='--no-colors' NVM_MIN=20.1 nvm_print_versions "$(nvm_remote_versions)" | sed -r 's/^[ \t]+//')"
|
|
||||||
EXPECTED_OUTPUT="-> v16.20.2 * (LTS: Gallium)
|
|
||||||
v16.20.3 (Latest LTS: Gallium)
|
|
||||||
v20.8.1
|
|
||||||
v20.9.0 (Latest LTS: Iron)
|
|
||||||
v21.0.0
|
|
||||||
v21.1.0"
|
|
||||||
|
|
||||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "(5) NVM_MIN=20.1 nvm_print_versions did not output all expected versions; got $OUTPUT"
|
|
||||||
|
|
||||||
|
|
||||||
cleanup
|
|
||||||
@@ -3,12 +3,16 @@
|
|||||||
setup () {
|
setup () {
|
||||||
HOME="."
|
HOME="."
|
||||||
NVM_ENV=testing \. ../../install.sh
|
NVM_ENV=testing \. ../../install.sh
|
||||||
|
ZDOTDIR="$HOME/zdotdir"
|
||||||
|
mkdir -p zdotdir
|
||||||
touch ".bashrc"
|
touch ".bashrc"
|
||||||
touch ".bash_profile"
|
touch ".bash_profile"
|
||||||
touch ".zprofile"
|
touch ".zprofile"
|
||||||
touch ".zshrc"
|
touch ".zshrc"
|
||||||
touch ".profile"
|
touch ".profile"
|
||||||
touch "test_profile"
|
touch "test_profile"
|
||||||
|
touch "zdotdir/.zshrc"
|
||||||
|
touch "zdotdir/.zprofile"
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup () {
|
cleanup () {
|
||||||
@@ -17,7 +21,9 @@ cleanup () {
|
|||||||
unset NVM_DETECT_PROFILE
|
unset NVM_DETECT_PROFILE
|
||||||
unset SHELL
|
unset SHELL
|
||||||
unset -f setup cleanup die
|
unset -f setup cleanup die
|
||||||
|
unset ZDOTDIR
|
||||||
rm -f ".bashrc" ".bash_profile" ".zprofile" ".zshrc" ".profile" "test_profile" > "/dev/null" 2>&1
|
rm -f ".bashrc" ".bash_profile" ".zprofile" ".zshrc" ".profile" "test_profile" > "/dev/null" 2>&1
|
||||||
|
rm -rf zdotdir 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
die () { echo "$@" '$NVM_DETECT_PROFILE:' "$NVM_DETECT_PROFILE"; cleanup; exit 1; }
|
die () { echo "$@" '$NVM_DETECT_PROFILE:' "$NVM_DETECT_PROFILE"; cleanup; exit 1; }
|
||||||
@@ -29,49 +35,54 @@ setup
|
|||||||
#
|
#
|
||||||
|
|
||||||
# setting $PROFILE to /dev/null should return no detected profile
|
# setting $PROFILE to /dev/null should return no detected profile
|
||||||
NVM_DETECT_PROFILE="$(PROFILE='/dev/null'; nvm_detect_profile)"
|
NVM_DETECT_PROFILE="$(PROFILE='/dev/null' nvm_detect_profile)"
|
||||||
if [ -n "$NVM_DETECT_PROFILE" ]; then
|
if [ -n "$NVM_DETECT_PROFILE" ]; then
|
||||||
die "nvm_detect_profile still detected a profile even though PROFILE=/dev/null"
|
die "nvm_detect_profile still detected a profile even though PROFILE=/dev/null"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# .bashrc should be detected for bash
|
# .bashrc should be detected for bash
|
||||||
NVM_DETECT_PROFILE="$(SHELL="/bin/bash"; unset PROFILE; nvm_detect_profile)"
|
NVM_DETECT_PROFILE="$(SHELL="/bin/bash" PROFILE= nvm_detect_profile)"
|
||||||
if [ "$NVM_DETECT_PROFILE" != "$HOME/.bashrc" ]; then
|
if [ "$NVM_DETECT_PROFILE" != "$HOME/.bashrc" ]; then
|
||||||
die "nvm_detect_profile didn't pick \$HOME/.bashrc for bash"
|
die "nvm_detect_profile didn't pick \$HOME/.bashrc for bash"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# $PROFILE should override .bashrc profile detection
|
# $PROFILE should override .bashrc profile detection
|
||||||
NVM_DETECT_PROFILE="$(SHELL="/bin/bash"; PROFILE="test_profile"; nvm_detect_profile)"
|
NVM_DETECT_PROFILE="$(SHELL="/bin/bash" PROFILE="test_profile" nvm_detect_profile)"
|
||||||
if [ "$NVM_DETECT_PROFILE" != "test_profile" ]; then
|
if [ "$NVM_DETECT_PROFILE" != "test_profile" ]; then
|
||||||
die "nvm_detect_profile ignored \$PROFILE"
|
die "nvm_detect_profile ignored \$PROFILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# zdotdir/.zshrc should be detected for zsh
|
||||||
|
NVM_DETECT_PROFILE="$(SHELL="/bin/zsh" PROFILE= nvm_detect_profile)"
|
||||||
|
if [ "$NVM_DETECT_PROFILE" != "$ZDOTDIR/.zshrc" ]; then
|
||||||
|
die "nvm_detect_profile didn't pick \$ZDOTDIR/.zshrc for zsh"
|
||||||
|
fi
|
||||||
|
|
||||||
# .zshrc should be detected for zsh
|
# .zshrc should be detected for zsh
|
||||||
NVM_DETECT_PROFILE="$(SHELL="/bin/zsh"; unset PROFILE; nvm_detect_profile)"
|
NVM_DETECT_PROFILE="$(SHELL="/bin/zsh" PROFILE= ZDOTDIR= nvm_detect_profile)"
|
||||||
if [ "$NVM_DETECT_PROFILE" != "$HOME/.zshrc" ]; then
|
if [ "$NVM_DETECT_PROFILE" != "$HOME/.zshrc" ]; then
|
||||||
die "nvm_detect_profile didn't pick \$HOME/.zshrc for zsh"
|
die "nvm_detect_profile didn't pick \$HOME/.zshrc for zsh"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# $PROFILE should override .zshrc profile detection
|
# $PROFILE should override .zshrc profile detection
|
||||||
NVM_DETECT_PROFILE="$(SHELL="/usr/bin/zsh"; PROFILE="test_profile"; nvm_detect_profile)"
|
NVM_DETECT_PROFILE="$(SHELL="/usr/bin/zsh" PROFILE="test_profile" nvm_detect_profile)"
|
||||||
if [ "$NVM_DETECT_PROFILE" != "test_profile" ]; then
|
if [ "$NVM_DETECT_PROFILE" != "test_profile" ]; then
|
||||||
die "nvm_detect_profile ignored \$PROFILE"
|
die "nvm_detect_profile ignored \$PROFILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Confirm $PROFILE is only returned when it points to a valid file
|
# Confirm $PROFILE is only returned when it points to a valid file
|
||||||
#
|
#
|
||||||
|
|
||||||
# $PROFILE is a valid file
|
# $PROFILE is a valid file
|
||||||
NVM_DETECT_PROFILE="$(PROFILE="test_profile"; unset SHELL; nvm_detect_profile)"
|
NVM_DETECT_PROFILE="$(PROFILE="test_profile" SHELL= nvm_detect_profile)"
|
||||||
if [ "$NVM_DETECT_PROFILE" != "test_profile" ]; then
|
if [ "$NVM_DETECT_PROFILE" != "test_profile" ]; then
|
||||||
die "nvm_detect_profile didn't pick \$PROFILE when it was a valid file"
|
die "nvm_detect_profile didn't pick \$PROFILE when it was a valid file"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# $PROFILE is not a valid file
|
# $PROFILE is not a valid file
|
||||||
rm "test_profile"
|
rm "test_profile"
|
||||||
NVM_DETECT_PROFILE="$(PROFILE="test_profile"; nvm_detect_profile)"
|
NVM_DETECT_PROFILE="$(PROFILE="test_profile" nvm_detect_profile)"
|
||||||
if [ "$NVM_DETECT_PROFILE" = "test_profile" ]; then
|
if [ "$NVM_DETECT_PROFILE" = "test_profile" ]; then
|
||||||
die "nvm_detect_profile picked \$PROFILE when it was an invalid file"
|
die "nvm_detect_profile picked \$PROFILE when it was an invalid file"
|
||||||
fi
|
fi
|
||||||
@@ -83,44 +94,58 @@ fi
|
|||||||
#
|
#
|
||||||
|
|
||||||
# It should favor .profile if file exists
|
# It should favor .profile if file exists
|
||||||
NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)"
|
NVM_DETECT_PROFILE="$(SHELL= ZDOTDIR= nvm_detect_profile)"
|
||||||
if [ "$NVM_DETECT_PROFILE" != "$HOME/.profile" ]; then
|
if [ "$NVM_DETECT_PROFILE" != "$HOME/.profile" ]; then
|
||||||
die "nvm_detect_profile should have selected .profile"
|
die "nvm_detect_profile should have selected .profile; got $NVM_DETECT_PROFILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Otherwise, it should favor .bashrc if file exists
|
# Otherwise, it should favor .bashrc if file exists
|
||||||
rm ".profile"
|
rm ".profile"
|
||||||
NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)"
|
NVM_DETECT_PROFILE="$(SHELL= ZDOTDIR= nvm_detect_profile)"
|
||||||
if [ "$NVM_DETECT_PROFILE" != "$HOME/.bashrc" ]; then
|
if [ "$NVM_DETECT_PROFILE" != "$HOME/.bashrc" ]; then
|
||||||
die "nvm_detect_profile should have selected .bashrc"
|
die "nvm_detect_profile should have selected .bashrc; got $NVM_DETECT_PROFILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Otherwise, it should favor .bash_profile if file exists
|
# Otherwise, it should favor .bash_profile if file exists
|
||||||
rm ".bashrc"
|
rm ".bashrc"
|
||||||
NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)"
|
NVM_DETECT_PROFILE="$(SHELL= ZDOTDIR= nvm_detect_profile)"
|
||||||
if [ "$NVM_DETECT_PROFILE" != "$HOME/.bash_profile" ]; then
|
if [ "$NVM_DETECT_PROFILE" != "$HOME/.bash_profile" ]; then
|
||||||
die "nvm_detect_profile should have selected .bash_profile"
|
die "nvm_detect_profile should have selected .bash_profile; got $NVM_DETECT_PROFILE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Otherwise, it should favor zdotdir/.zprofile if file exists
|
||||||
|
rm ".bash_profile"
|
||||||
|
NVM_DETECT_PROFILE="$(SHELL= nvm_detect_profile)"
|
||||||
|
if [ "$NVM_DETECT_PROFILE" != "$ZDOTDIR/.zprofile" ]; then
|
||||||
|
die "nvm_detect_profile should have selected zdotdir/.zprofile; got $NVM_DETECT_PROFILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Otherwise, it should favor .zprofile if file exists
|
# Otherwise, it should favor .zprofile if file exists
|
||||||
rm ".bash_profile"
|
rm "zdotdir/.zprofile"
|
||||||
NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)"
|
NVM_DETECT_PROFILE="$(SHELL= ZDOTDIR= nvm_detect_profile)"
|
||||||
if [ "$NVM_DETECT_PROFILE" != "$HOME/.zprofile" ]; then
|
if [ "$NVM_DETECT_PROFILE" != "$HOME/.zprofile" ]; then
|
||||||
die "nvm_detect_profile should have selected .zprofile"
|
die "nvm_detect_profile should have selected .zprofile; got $NVM_DETECT_PROFILE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Otherwise, it should favor zdotdir/.zshrc if file exists
|
||||||
|
rm ".zprofile"
|
||||||
|
NVM_DETECT_PROFILE="$(SHELL= nvm_detect_profile)"
|
||||||
|
if [ "$NVM_DETECT_PROFILE" != "$ZDOTDIR/.zshrc" ]; then
|
||||||
|
die "nvm_detect_profile should have selected zdotdir/.zshrc; got $NVM_DETECT_PROFILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Otherwise, it should favor .zshrc if file exists
|
# Otherwise, it should favor .zshrc if file exists
|
||||||
rm ".zprofile"
|
rm "zdotdir/.zshrc"
|
||||||
NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)"
|
NVM_DETECT_PROFILE="$(SHELL= ZDOTDIR= nvm_detect_profile)"
|
||||||
if [ "$NVM_DETECT_PROFILE" != "$HOME/.zshrc" ]; then
|
if [ "$NVM_DETECT_PROFILE" != "$HOME/.zshrc" ]; then
|
||||||
die "nvm_detect_profile should have selected .zshrc"
|
die "nvm_detect_profile should have selected .zshrc; got $NVM_DETECT_PROFILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# It should be empty if none is found
|
# It should be empty if none is found
|
||||||
rm ".zshrc"
|
rm ".zshrc"
|
||||||
NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)"
|
NVM_DETECT_PROFILE="$(SHELL= nvm_detect_profile)"
|
||||||
if [ ! -z "$NVM_DETECT_PROFILE" ]; then
|
if [ ! -z "$NVM_DETECT_PROFILE" ]; then
|
||||||
die "nvm_detect_profile should have returned an empty value"
|
die "nvm_detect_profile should have returned an empty value; got $NVM_DETECT_PROFILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cleanup
|
cleanup
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ die () { echo "$@" ; exit 1; }
|
|||||||
\. ../../../nvm.sh
|
\. ../../../nvm.sh
|
||||||
|
|
||||||
# Version to install/uninstall
|
# Version to install/uninstall
|
||||||
NVM_TEST_VERSION=5.10.1
|
NVM_TEST_VERSION=15.5.0
|
||||||
|
|
||||||
# Make sure it's not already here
|
# Make sure it's not already here
|
||||||
[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION
|
[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION
|
||||||
@@ -19,7 +19,9 @@ nvm ls | grep "$NVM_TEST_VERSION" || die "Failed to install node"
|
|||||||
|
|
||||||
# Install global module as root
|
# Install global module as root
|
||||||
npm_path=$(which npm)
|
npm_path=$(which npm)
|
||||||
sudo -n "$npm_path" install jspm@'<2' -g || die 'either sudo failed, or `npm install jspm -g` failed`'
|
nvm_err "${PATH}"
|
||||||
|
PATH="${PATH}" sudo -n echo "${PATH}" || die 'sudo echo failed'
|
||||||
|
PATH="${PATH}" sudo -n "$npm_path" install jspm@'<2' -g || die 'either sudo failed, or `npm install jspm -g` failed`'
|
||||||
|
|
||||||
# Switch to another version so we can uninstall
|
# Switch to another version so we can uninstall
|
||||||
nvm use 0.12.7
|
nvm use 0.12.7
|
||||||
|
|||||||
Reference in New Issue
Block a user