mirror of
https://github.com/nvm-sh/nvm.git
synced 2026-02-04 17:02:48 +08:00
Compare commits
3 Commits
630a01f2e0
...
fix-nvmrc-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
26066c10f4 | ||
|
|
34d6d5d6fe | ||
|
|
80cc4cdd1b |
2
.github/workflows/latest-npm.yml
vendored
2
.github/workflows/latest-npm.yml
vendored
@@ -63,7 +63,7 @@ jobs:
|
||||
iojs.org:443
|
||||
nodejs.org:443
|
||||
registry.npmjs.org:443
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
- uses: ljharb/actions/node/install@main
|
||||
name: 'install node'
|
||||
with:
|
||||
|
||||
8
.github/workflows/lint.yml
vendored
8
.github/workflows/lint.yml
vendored
@@ -16,7 +16,7 @@ jobs:
|
||||
raw.githubusercontent.com:443
|
||||
nodejs.org:443
|
||||
registry.npmjs.org:443
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
- uses: ljharb/actions/node/install@main
|
||||
name: 'nvm install ${{ matrix.node-version }} && npm install'
|
||||
with:
|
||||
@@ -35,7 +35,7 @@ jobs:
|
||||
pkg-containers.githubusercontent.com:443
|
||||
nodejs.org:443
|
||||
registry.npmjs.org:443
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
- uses: ljharb/actions/node/install@main
|
||||
name: 'nvm install ${{ matrix.node-version }} && npm install'
|
||||
with:
|
||||
@@ -52,7 +52,7 @@ jobs:
|
||||
raw.githubusercontent.com:443
|
||||
nodejs.org:443
|
||||
registry.npmjs.org:443
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
- uses: ljharb/actions/node/install@main
|
||||
name: 'nvm install ${{ matrix.node-version }} && npm install'
|
||||
with:
|
||||
@@ -67,6 +67,6 @@ jobs:
|
||||
allowed-endpoints:
|
||||
github.com:443
|
||||
raw.githubusercontent.com:443
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
- name: check tests filenames
|
||||
run: ./rename_test.sh --check
|
||||
|
||||
4
.github/workflows/nvm-install-test.yml
vendored
4
.github/workflows/nvm-install-test.yml
vendored
@@ -16,7 +16,7 @@ jobs:
|
||||
outputs:
|
||||
matrix: ${{ steps.matrix.outputs.matrix }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- id: matrix
|
||||
@@ -55,7 +55,7 @@ jobs:
|
||||
- 2 shlvls
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
- name: resolve HEAD to sha
|
||||
run: |
|
||||
if [ '${{ matrix.ref }}' = 'HEAD' ]; then
|
||||
|
||||
2
.github/workflows/rebase.yml
vendored
2
.github/workflows/rebase.yml
vendored
@@ -11,7 +11,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v6
|
||||
- uses: ljharb/rebase@master
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
@@ -19,10 +19,10 @@ jobs:
|
||||
raw.githubusercontent.com:443
|
||||
release-assets.githubusercontent.com:443
|
||||
registry.npmjs.org:443
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-tags: true
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: "14"
|
||||
- run: npm install
|
||||
|
||||
2
.github/workflows/shellcheck.yml
vendored
2
.github/workflows/shellcheck.yml
vendored
@@ -35,7 +35,7 @@ jobs:
|
||||
github.com:443
|
||||
pkg-containers.githubusercontent.com:443
|
||||
formulae.brew.sh:443
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
- name: Set up Homebrew
|
||||
uses: Homebrew/actions/setup-homebrew@master
|
||||
- name: Install latest shellcheck
|
||||
|
||||
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
@@ -52,7 +52,7 @@ jobs:
|
||||
iojs.org:443
|
||||
azure.archive.ubuntu.com:80
|
||||
packages.microsoft.com:443
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
- run: sudo apt-get update; sudo apt-get install ${{ matrix.shell }}
|
||||
if: matrix.shell == 'zsh' || matrix.shell == 'ksh'
|
||||
# zsh (https://github.com/actions/runner-images/issues/264) and ksh are not in the ubuntu image
|
||||
|
||||
4
.github/workflows/toc.yml
vendored
4
.github/workflows/toc.yml
vendored
@@ -21,7 +21,7 @@ jobs:
|
||||
github.com:443
|
||||
registry.npmjs.org:443
|
||||
api.github.com:443
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
# https://github.com/actions/checkout/issues/217#issue-599945005
|
||||
# pulls all commits (needed for lerna / semantic release to correctly version)
|
||||
@@ -29,7 +29,7 @@ jobs:
|
||||
|
||||
# pulls all tags (needed for lerna / semantic release to correctly version)
|
||||
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
- run: npm install
|
||||
|
||||
55
.github/workflows/windows-npm.yml
vendored
55
.github/workflows/windows-npm.yml
vendored
@@ -125,23 +125,55 @@ jobs:
|
||||
npm-node-version: '21'
|
||||
- wsl-distrib: Ubuntu-18.04
|
||||
npm-node-version: '18'
|
||||
# node v24+ doesn't work on WSL1 (exec format error)
|
||||
- wsl-distrib: Debian
|
||||
npm-node-version: '--lts'
|
||||
- wsl-distrib: Ubuntu-20.04
|
||||
npm-node-version: '--lts'
|
||||
method:
|
||||
- ''
|
||||
- 'script'
|
||||
steps:
|
||||
- uses: Vampire/setup-wsl@v3
|
||||
# For Ubuntu: install with packages directly
|
||||
- if: matrix.wsl-distrib != 'Debian'
|
||||
uses: Vampire/setup-wsl@v3
|
||||
with:
|
||||
distribution: ${{ matrix.wsl-distrib }}
|
||||
additional-packages: bash git curl ca-certificates wget
|
||||
|
||||
# see https://github.com/Vampire/setup-wsl/issues/76#issuecomment-3258201135
|
||||
- shell: 'wsl-bash {0}'
|
||||
run: 'sed -i s/ftp.debian.org/archive.debian.org/ /etc/apt/sources.list'
|
||||
- uses: Vampire/setup-wsl@v3
|
||||
# For Debian: install without packages first (apt-get update fails due to stale sources.list)
|
||||
# see https://github.com/Vampire/setup-wsl/issues/76
|
||||
- if: matrix.wsl-distrib == 'Debian'
|
||||
uses: Vampire/setup-wsl@v3
|
||||
with:
|
||||
distribution: ${{ matrix.wsl-distrib }}
|
||||
additional-packages: bash git curl ca-certificates wget
|
||||
update: 'true'
|
||||
- if: matrix.wsl-distrib == 'Debian'
|
||||
shell: 'wsl-bash {0}'
|
||||
run: 'sed -i s/ftp.debian.org/archive.debian.org/ /etc/apt/sources.list'
|
||||
- if: matrix.wsl-distrib == 'Debian'
|
||||
name: 'Install packages with retries'
|
||||
shell: 'wsl-bash {0}'
|
||||
run: |
|
||||
retry() {
|
||||
local n=0
|
||||
local max=3
|
||||
local delay=5
|
||||
while true; do
|
||||
"$@" && break || {
|
||||
n=$((n+1))
|
||||
if [ $n -lt $max ]; then
|
||||
echo "Command failed. Attempt $n/$max. Retrying in $delay seconds..."
|
||||
sleep $delay
|
||||
else
|
||||
echo "Command failed after $max attempts."
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
done
|
||||
}
|
||||
retry apt-get update
|
||||
retry apt-get upgrade --yes
|
||||
retry apt-get install --yes bash git curl ca-certificates wget
|
||||
|
||||
- name: Retrieve nvm on WSL
|
||||
run: |
|
||||
@@ -187,15 +219,6 @@ jobs:
|
||||
distribution: ${{ matrix.wsl-distrib }}
|
||||
additional-packages: bash git curl ca-certificates wget
|
||||
|
||||
# see https://github.com/Vampire/setup-wsl/issues/76#issuecomment-3258201135
|
||||
- shell: 'wsl-bash {0}'
|
||||
run: 'sed -i s/ftp.debian.org/archive.debian.org/ /etc/apt/sources.list'
|
||||
- uses: Vampire/setup-wsl@v3
|
||||
with:
|
||||
distribution: ${{ matrix.wsl-distrib }}
|
||||
additional-packages: bash git curl ca-certificates wget
|
||||
update: 'true'
|
||||
|
||||
- name: Retrieve nvm on WSL
|
||||
run: |
|
||||
if [ -z "${{ matrix.method }}" ]; then
|
||||
|
||||
4
nvm.sh
4
nvm.sh
@@ -1294,7 +1294,7 @@ nvm_alias() {
|
||||
return 2
|
||||
fi
|
||||
|
||||
command awk 'NF' "${NVM_ALIAS_PATH}"
|
||||
command sed 's/#.*//; s/[[:space:]]*$//' "${NVM_ALIAS_PATH}" | command awk 'NF'
|
||||
}
|
||||
|
||||
nvm_ls_current() {
|
||||
@@ -1529,7 +1529,7 @@ nvm_ls() {
|
||||
PATTERN='v'
|
||||
SEARCH_PATTERN='.*'
|
||||
else
|
||||
SEARCH_PATTERN="$(nvm_echo "${PATTERN}" | command sed 's#\.#\\\.#g;')"
|
||||
SEARCH_PATTERN="$(nvm_echo "${PATTERN}" | command sed 's#\.#\\\.#g; s|#|\\#|g')"
|
||||
fi
|
||||
if [ -n "${NVM_DIRS_TO_SEARCH1}${NVM_DIRS_TO_SEARCH2}${NVM_DIRS_TO_SEARCH3}" ]; then
|
||||
VERSIONS="$(command find "${NVM_DIRS_TO_SEARCH1}"/* "${NVM_DIRS_TO_SEARCH2}"/* "${NVM_DIRS_TO_SEARCH3}"/* -name . -o -type d -prune -o -path "${PATTERN}*" \
|
||||
|
||||
33
test/fast/Unit tests/nvm_alias handles comments
Executable file
33
test/fast/Unit tests/nvm_alias handles comments
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo "$@" ; cleanup ; exit 1; }
|
||||
|
||||
cleanup () {
|
||||
rm -rf ../../../alias/test-comment
|
||||
rm -rf ../../../alias/test-inline-comment
|
||||
rm -rf ../../../alias/test-comment-first
|
||||
}
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
# Test: alias file with comment on separate line
|
||||
echo "v0.10
|
||||
# this is a comment" > ../../../alias/test-comment
|
||||
OUTPUT="$(nvm_alias test-comment)"
|
||||
EXPECTED_OUTPUT="v0.10"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_alias test-comment' should ignore comment line; expected '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
||||
|
||||
# Test: alias file with inline comment
|
||||
echo "v0.11 # inline comment" > ../../../alias/test-inline-comment
|
||||
OUTPUT="$(nvm_alias test-inline-comment)"
|
||||
EXPECTED_OUTPUT="v0.11"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_alias test-inline-comment' should strip inline comment; expected '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
||||
|
||||
# Test: alias file with comment as first line
|
||||
echo "# comment first
|
||||
v0.12" > ../../../alias/test-comment-first
|
||||
OUTPUT="$(nvm_alias test-comment-first)"
|
||||
EXPECTED_OUTPUT="v0.12"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_alias test-comment-first' should skip comment-only first line; expected '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
||||
|
||||
cleanup
|
||||
23
test/fast/Unit tests/nvm_ls handles hash in pattern
Executable file
23
test/fast/Unit tests/nvm_ls handles hash in pattern
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
# Test: nvm_ls with pattern containing # should not cause sed error
|
||||
# This is a regression test for https://github.com/nvm-sh/nvm/issues/3761
|
||||
|
||||
# The pattern with # should not cause sed "unterminated regular expression" error
|
||||
# It's OK if it returns N/A (no match), but it should not produce sed errors
|
||||
OUTPUT="$(nvm_ls 'foo#bar' 2>&1)"
|
||||
EXIT_CODE=$?
|
||||
|
||||
# Check that output doesn't contain sed error message
|
||||
echo "$OUTPUT" | grep -q "unterminated regular expression" && \
|
||||
die "nvm_ls with # in pattern caused sed 'unterminated regular expression' error: $OUTPUT"
|
||||
echo "$OUTPUT" | grep -q "invalid command code" && \
|
||||
die "nvm_ls with # in pattern caused sed 'invalid command code' error: $OUTPUT"
|
||||
|
||||
# Should return N/A with exit code 3 (not found)
|
||||
[ "$EXIT_CODE" = "3" ] || die "nvm_ls 'foo#bar' should exit with code 3, got $EXIT_CODE"
|
||||
echo "$OUTPUT" | grep -q "N/A" || die "nvm_ls 'foo#bar' should output N/A, got: $OUTPUT"
|
||||
Reference in New Issue
Block a user