mirror of
https://github.com/nvm-sh/nvm.git
synced 2026-02-08 02:42:48 +08:00
Compare commits
10 Commits
fix-nvmrc-
...
76c61c9845
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
76c61c9845 | ||
|
|
3c7a5654f5 | ||
|
|
7346ee6523 | ||
|
|
ec8906b284 | ||
|
|
0509776196 | ||
|
|
01a8749d7f | ||
|
|
0fbe3a6776 | ||
|
|
a36448ffcd | ||
|
|
4d364c2e7b | ||
|
|
81f13638d7 |
7
.github/SECURITY.md
vendored
7
.github/SECURITY.md
vendored
@@ -2,6 +2,13 @@
|
|||||||
|
|
||||||
Please file a private vulnerability report via GitHub, email [@ljharb](https://github.com/ljharb), or see https://tidelift.com/security if you have a potential security vulnerability to report.
|
Please file a private vulnerability report via GitHub, email [@ljharb](https://github.com/ljharb), or see https://tidelift.com/security if you have a potential security vulnerability to report.
|
||||||
|
|
||||||
|
## Escalation
|
||||||
|
|
||||||
|
If you do not receive an acknowledgement of your report within 6 business days, or if you cannot find a private security contact for the project, you may escalate to the OpenJS Foundation CNA at `security@lists.openjsf.org`.
|
||||||
|
|
||||||
|
If the project acknowledges your report but does not provide any further response or engagement within 14 days, escalation is also appropriate.
|
||||||
|
|
||||||
|
|
||||||
## OpenSSF CII Best Practices
|
## OpenSSF CII Best Practices
|
||||||
|
|
||||||
[](https://bestpractices.coreinfrastructure.org/projects/684)
|
[](https://bestpractices.coreinfrastructure.org/projects/684)
|
||||||
|
|||||||
101
.github/workflows/tests-fast.yml
vendored
Normal file
101
.github/workflows/tests-fast.yml
vendored
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
name: 'Tests: fast'
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
fast:
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
name: 'fast (${{ matrix.shell }}, ${{ matrix.awk }})'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: 'script -q -e -c "${{ matrix.shell }} {0}"'
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
shell:
|
||||||
|
- sh
|
||||||
|
- bash
|
||||||
|
- dash
|
||||||
|
- zsh
|
||||||
|
# - ksh
|
||||||
|
awk:
|
||||||
|
- gawk
|
||||||
|
- mawk
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Harden Runner
|
||||||
|
uses: step-security/harden-runner@v2
|
||||||
|
with:
|
||||||
|
allowed-endpoints:
|
||||||
|
github.com:443
|
||||||
|
registry.npmjs.org:443
|
||||||
|
raw.githubusercontent.com:443
|
||||||
|
nodejs.org:443
|
||||||
|
iojs.org:443
|
||||||
|
unofficial-builds.nodejs.org:443
|
||||||
|
azure.archive.ubuntu.com:80
|
||||||
|
packages.microsoft.com:443
|
||||||
|
registry-1.docker.io:443
|
||||||
|
auth.docker.io:443
|
||||||
|
production.cloudflare.docker.com:443
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
- name: Install zsh, additional shells, and awk variant
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y zsh ${{ matrix.awk }}
|
||||||
|
if [ "${{ matrix.shell }}" != "sh" ] && [ "${{ matrix.shell }}" != "bash" ] && [ "${{ matrix.shell }}" != "zsh" ]; then
|
||||||
|
sudo apt-get install -y ${{ matrix.shell }}
|
||||||
|
fi
|
||||||
|
# Set the selected awk as the default
|
||||||
|
sudo update-alternatives --set awk /usr/bin/${{ matrix.awk }}
|
||||||
|
shell: bash
|
||||||
|
- run: sudo ${{ matrix.shell }} --version 2> /dev/null || dpkg -s ${{ matrix.shell }} 2> /dev/null || which ${{ matrix.shell }}
|
||||||
|
- run: awk --version 2>&1 | head -1 || awk -W version 2>&1 | head -1
|
||||||
|
- run: curl --version
|
||||||
|
- run: wget --version
|
||||||
|
- uses: ljharb/actions/node/install@main
|
||||||
|
name: 'npm install && version checks'
|
||||||
|
with:
|
||||||
|
node-version: 'lts/*'
|
||||||
|
skip-ls-check: true
|
||||||
|
- run: npm ls urchin
|
||||||
|
- run: npx which urchin
|
||||||
|
- run: env
|
||||||
|
- name: Hide system node
|
||||||
|
run: |
|
||||||
|
if [ -f /usr/local/bin/node ]; then sudo mv /usr/local/bin/node /usr/local/bin/node.bak; fi
|
||||||
|
if [ -f /usr/local/bin/npm ]; then sudo mv /usr/local/bin/npm /usr/local/bin/npm.bak; fi
|
||||||
|
if [ -f /usr/local/bin/npx ]; then sudo mv /usr/local/bin/npx /usr/local/bin/npx.bak; fi
|
||||||
|
shell: bash
|
||||||
|
- name: Run fast tests
|
||||||
|
run: |
|
||||||
|
URCHIN_PATH="$(npx which urchin)"
|
||||||
|
unset NVM_CD_FLAGS NVM_BIN NVM_INC
|
||||||
|
export NVM_DIR="${{ github.workspace }}"
|
||||||
|
export PATH="$(echo "$PATH" | tr ':' '\n' | grep -v '\.nvm' | grep -v 'toolcache' | tr '\n' ':')"
|
||||||
|
make TERM=xterm-256color TEST_SUITE="fast" SHELL="${{ matrix.shell }}" URCHIN="$URCHIN_PATH" test-${{ matrix.shell }}
|
||||||
|
- name: Restore system node
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
if [ -f /usr/local/bin/node.bak ]; then sudo mv /usr/local/bin/node.bak /usr/local/bin/node; fi
|
||||||
|
if [ -f /usr/local/bin/npm.bak ]; then sudo mv /usr/local/bin/npm.bak /usr/local/bin/npm; fi
|
||||||
|
if [ -f /usr/local/bin/npx.bak ]; then sudo mv /usr/local/bin/npx.bak /usr/local/bin/npx; fi
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
all:
|
||||||
|
permissions:
|
||||||
|
contents: none
|
||||||
|
name: 'all fast tests'
|
||||||
|
needs: [fast]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- run: true
|
||||||
99
.github/workflows/tests-installation-iojs.yml
vendored
Normal file
99
.github/workflows/tests-installation-iojs.yml
vendored
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
name: 'Tests: installation_iojs'
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
installation_iojs_without_curl:
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
name: 'installation_iojs without curl (${{ matrix.shell }})'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: 'script -q -e -c "${{ matrix.shell }} {0}"'
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
shell:
|
||||||
|
- sh
|
||||||
|
- bash
|
||||||
|
- dash
|
||||||
|
- zsh
|
||||||
|
# - ksh
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Harden Runner
|
||||||
|
uses: step-security/harden-runner@v2
|
||||||
|
with:
|
||||||
|
allowed-endpoints:
|
||||||
|
github.com:443
|
||||||
|
registry.npmjs.org:443
|
||||||
|
raw.githubusercontent.com:443
|
||||||
|
nodejs.org:443
|
||||||
|
iojs.org:443
|
||||||
|
azure.archive.ubuntu.com:80
|
||||||
|
packages.microsoft.com:443
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
- name: Install zsh and additional shells
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y zsh
|
||||||
|
if [ "${{ matrix.shell }}" != "sh" ] && [ "${{ matrix.shell }}" != "bash" ] && [ "${{ matrix.shell }}" != "zsh" ]; then
|
||||||
|
sudo apt-get install -y ${{ matrix.shell }}
|
||||||
|
fi
|
||||||
|
shell: bash
|
||||||
|
- run: sudo ${{ matrix.shell }} --version 2> /dev/null || dpkg -s ${{ matrix.shell }} 2> /dev/null || which ${{ matrix.shell }}
|
||||||
|
- run: wget --version
|
||||||
|
- uses: ljharb/actions/node/install@main
|
||||||
|
name: 'npm install && version checks'
|
||||||
|
with:
|
||||||
|
node-version: 'lts/*'
|
||||||
|
skip-ls-check: true
|
||||||
|
- run: npm ls urchin
|
||||||
|
- run: npx which urchin
|
||||||
|
- name: Remove curl
|
||||||
|
run: sudo apt-get remove curl -y
|
||||||
|
shell: bash
|
||||||
|
- run: '! command -v curl'
|
||||||
|
shell: bash
|
||||||
|
- run: env
|
||||||
|
- name: Hide system node
|
||||||
|
run: |
|
||||||
|
if [ -f /usr/local/bin/node ]; then sudo mv /usr/local/bin/node /usr/local/bin/node.bak; fi
|
||||||
|
if [ -f /usr/local/bin/npm ]; then sudo mv /usr/local/bin/npm /usr/local/bin/npm.bak; fi
|
||||||
|
if [ -f /usr/local/bin/npx ]; then sudo mv /usr/local/bin/npx /usr/local/bin/npx.bak; fi
|
||||||
|
shell: bash
|
||||||
|
- name: Run installation_iojs tests
|
||||||
|
run: |
|
||||||
|
URCHIN_PATH="$(npx which urchin)"
|
||||||
|
unset NVM_CD_FLAGS NVM_BIN NVM_INC
|
||||||
|
export NVM_DIR="${{ github.workspace }}"
|
||||||
|
export PATH="$(echo "$PATH" | tr ':' '\n' | grep -v '\.nvm' | grep -v 'toolcache' | tr '\n' ':')"
|
||||||
|
make TERM=xterm-256color TEST_SUITE="installation_iojs" SHELL="${{ matrix.shell }}" URCHIN="$URCHIN_PATH" test-${{ matrix.shell }}
|
||||||
|
- name: Restore system node
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
if [ -f /usr/local/bin/node.bak ]; then sudo mv /usr/local/bin/node.bak /usr/local/bin/node; fi
|
||||||
|
if [ -f /usr/local/bin/npm.bak ]; then sudo mv /usr/local/bin/npm.bak /usr/local/bin/npm; fi
|
||||||
|
if [ -f /usr/local/bin/npx.bak ]; then sudo mv /usr/local/bin/npx.bak /usr/local/bin/npx; fi
|
||||||
|
shell: bash
|
||||||
|
- name: Restore curl
|
||||||
|
if: always()
|
||||||
|
run: sudo apt-get install curl -y
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
all:
|
||||||
|
permissions:
|
||||||
|
contents: none
|
||||||
|
name: 'all installation_iojs tests'
|
||||||
|
needs: [installation_iojs_without_curl]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- run: true
|
||||||
122
.github/workflows/tests-installation-node.yml
vendored
Normal file
122
.github/workflows/tests-installation-node.yml
vendored
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
name: 'Tests: installation_node'
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
installation_node:
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
name: "installation_node (${{ matrix.shell }}${{ matrix.without_curl && ', without curl' || '' }})"
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
shell:
|
||||||
|
- sh
|
||||||
|
- bash
|
||||||
|
- dash
|
||||||
|
- zsh
|
||||||
|
# - ksh
|
||||||
|
without_curl:
|
||||||
|
- false
|
||||||
|
- true
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Harden Runner
|
||||||
|
uses: step-security/harden-runner@v2
|
||||||
|
with:
|
||||||
|
allowed-endpoints:
|
||||||
|
github.com:443
|
||||||
|
registry.npmjs.org:443
|
||||||
|
raw.githubusercontent.com:443
|
||||||
|
nodejs.org:443
|
||||||
|
iojs.org:443
|
||||||
|
azure.archive.ubuntu.com:80
|
||||||
|
packages.microsoft.com:443
|
||||||
|
archive.ubuntu.com:80
|
||||||
|
security.ubuntu.com:80
|
||||||
|
production.cloudflare.docker.com:443
|
||||||
|
registry-1.docker.io:443
|
||||||
|
auth.docker.io:443
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
- uses: ljharb/actions/node/install@main
|
||||||
|
name: 'npm install && version checks'
|
||||||
|
with:
|
||||||
|
node-version: 'lts/*'
|
||||||
|
skip-ls-check: true
|
||||||
|
- run: npm ls urchin
|
||||||
|
- run: npx which urchin
|
||||||
|
- name: Run installation_node tests in container
|
||||||
|
run: |
|
||||||
|
docker run --rm \
|
||||||
|
-v "${{ github.workspace }}:/workspace" \
|
||||||
|
-w /workspace \
|
||||||
|
-e "TEST_SHELL=${{ matrix.shell }}" \
|
||||||
|
-e "TERM=xterm-256color" \
|
||||||
|
-e "DEBIAN_FRONTEND=noninteractive" \
|
||||||
|
-e "GITHUB_ACTIONS=true" \
|
||||||
|
-e "WITHOUT_CURL=${{ matrix.without_curl }}" \
|
||||||
|
ubuntu:16.04 \
|
||||||
|
bash -c '
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
# Retry apt-get update up to 5 times due to flaky Ubuntu mirrors
|
||||||
|
# apt-get update can return 0 even with partial failures, so check for warnings
|
||||||
|
for i in 1 2 3 4 5; do
|
||||||
|
if apt-get update 2>&1 | tee /tmp/apt-update.log | grep -qE "^(W:|E:|Err:)"; then
|
||||||
|
echo "apt-get update had warnings/errors, attempt $i/5"
|
||||||
|
cat /tmp/apt-update.log
|
||||||
|
sleep $((i * 5))
|
||||||
|
else
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
apt-get install -y git curl wget make build-essential python zsh libssl-dev
|
||||||
|
if [ "$TEST_SHELL" != "sh" ] && [ "$TEST_SHELL" != "bash" ]; then
|
||||||
|
apt-get install -y $TEST_SHELL || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use nvm to install Node.js for running urchin
|
||||||
|
# Node 16 is the last version supporting GLIBC 2.23 (Ubuntu 16.04)
|
||||||
|
export NVM_DIR="/workspace"
|
||||||
|
. /workspace/nvm.sh
|
||||||
|
nvm install 16
|
||||||
|
nvm use 16
|
||||||
|
|
||||||
|
npm ls urchin
|
||||||
|
URCHIN_PATH="$(npx which urchin)"
|
||||||
|
|
||||||
|
# Remove curl if testing without it
|
||||||
|
if [ "$WITHOUT_CURL" = "true" ]; then
|
||||||
|
apt-get remove curl -y
|
||||||
|
! command -v curl
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Now clean up nvm state for the actual tests, but keep NVM_DIR set
|
||||||
|
nvm deactivate || true
|
||||||
|
nvm unalias default || true
|
||||||
|
unset NVM_CD_FLAGS NVM_BIN NVM_INC
|
||||||
|
export PATH="$(echo "$PATH" | tr ":" "\n" | grep -v "\.nvm" | grep -v "toolcache" | tr "\n" ":")"
|
||||||
|
|
||||||
|
# Clean any cached files from the nvm install above
|
||||||
|
rm -rf "$NVM_DIR/.cache" "$NVM_DIR/versions" "$NVM_DIR/alias"
|
||||||
|
|
||||||
|
make TEST_SUITE="installation_node" SHELL="$TEST_SHELL" URCHIN="$URCHIN_PATH" test-$TEST_SHELL
|
||||||
|
'
|
||||||
|
|
||||||
|
all:
|
||||||
|
permissions:
|
||||||
|
contents: none
|
||||||
|
name: 'all installation_node tests'
|
||||||
|
needs: [installation_node]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- run: true
|
||||||
112
.github/workflows/tests-xenial.yml
vendored
Normal file
112
.github/workflows/tests-xenial.yml
vendored
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
name: 'Tests: xenial'
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
xenial:
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
name: 'xenial (${{ matrix.shell }})'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
shell:
|
||||||
|
- sh
|
||||||
|
- bash
|
||||||
|
- dash
|
||||||
|
- zsh
|
||||||
|
# - ksh
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Harden Runner
|
||||||
|
uses: step-security/harden-runner@v2
|
||||||
|
with:
|
||||||
|
allowed-endpoints:
|
||||||
|
github.com:443
|
||||||
|
registry.npmjs.org:443
|
||||||
|
raw.githubusercontent.com:443
|
||||||
|
nodejs.org:443
|
||||||
|
iojs.org:443
|
||||||
|
azure.archive.ubuntu.com:80
|
||||||
|
packages.microsoft.com:443
|
||||||
|
archive.ubuntu.com:80
|
||||||
|
security.ubuntu.com:80
|
||||||
|
production.cloudflare.docker.com:443
|
||||||
|
registry-1.docker.io:443
|
||||||
|
auth.docker.io:443
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
- uses: ljharb/actions/node/install@main
|
||||||
|
name: 'npm install && version checks'
|
||||||
|
with:
|
||||||
|
node-version: 'lts/*'
|
||||||
|
skip-ls-check: true
|
||||||
|
- run: npm ls urchin
|
||||||
|
- run: npx which urchin
|
||||||
|
- name: Run xenial tests in container
|
||||||
|
run: |
|
||||||
|
docker run --rm \
|
||||||
|
-v "${{ github.workspace }}:/workspace" \
|
||||||
|
-w /workspace \
|
||||||
|
-e "TEST_SHELL=${{ matrix.shell }}" \
|
||||||
|
-e "TERM=xterm-256color" \
|
||||||
|
-e "DEBIAN_FRONTEND=noninteractive" \
|
||||||
|
-e "GITHUB_ACTIONS=true" \
|
||||||
|
ubuntu:16.04 \
|
||||||
|
bash -c '
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
# Retry apt-get update up to 5 times due to flaky Ubuntu mirrors
|
||||||
|
# apt-get update can return 0 even with partial failures, so check for warnings
|
||||||
|
for i in 1 2 3 4 5; do
|
||||||
|
if apt-get update 2>&1 | tee /tmp/apt-update.log | grep -qE "^(W:|E:|Err:)"; then
|
||||||
|
echo "apt-get update had warnings/errors, attempt $i/5"
|
||||||
|
cat /tmp/apt-update.log
|
||||||
|
sleep $((i * 5))
|
||||||
|
else
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
apt-get install -y git curl wget make build-essential python zsh libssl-dev
|
||||||
|
if [ "$TEST_SHELL" != "sh" ] && [ "$TEST_SHELL" != "bash" ]; then
|
||||||
|
apt-get install -y $TEST_SHELL || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use nvm to install Node.js for running urchin
|
||||||
|
# Node 16 is the last version supporting GLIBC 2.23 (Ubuntu 16.04)
|
||||||
|
export NVM_DIR="/workspace"
|
||||||
|
. /workspace/nvm.sh
|
||||||
|
nvm install 16
|
||||||
|
nvm use 16
|
||||||
|
|
||||||
|
npm ls urchin
|
||||||
|
URCHIN_PATH="$(npx which urchin)"
|
||||||
|
|
||||||
|
# Now clean up nvm state for the actual tests, but keep NVM_DIR set
|
||||||
|
nvm deactivate || true
|
||||||
|
nvm unalias default || true
|
||||||
|
unset NVM_CD_FLAGS NVM_BIN NVM_INC
|
||||||
|
export PATH="$(echo "$PATH" | tr ":" "\n" | grep -v "\.nvm" | grep -v "toolcache" | tr "\n" ":")"
|
||||||
|
|
||||||
|
# Clean any cached files from the nvm install above
|
||||||
|
rm -rf "$NVM_DIR/.cache" "$NVM_DIR/versions" "$NVM_DIR/alias"
|
||||||
|
|
||||||
|
make TEST_SUITE="xenial" SHELL="$TEST_SHELL" URCHIN="$URCHIN_PATH" test-$TEST_SHELL
|
||||||
|
'
|
||||||
|
|
||||||
|
all:
|
||||||
|
permissions:
|
||||||
|
contents: none
|
||||||
|
name: 'all xenial tests'
|
||||||
|
needs: [xenial]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- run: true
|
||||||
94
.travis.yml
94
.travis.yml
@@ -1,94 +0,0 @@
|
|||||||
language: generic
|
|
||||||
dist: focal
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- zsh
|
|
||||||
# - ksh
|
|
||||||
# - gcc-4.8
|
|
||||||
# - g++-4.8
|
|
||||||
|
|
||||||
# https://gist.github.com/iedemam/9830045
|
|
||||||
git:
|
|
||||||
submodules: false
|
|
||||||
|
|
||||||
cache:
|
|
||||||
ccache: true
|
|
||||||
directories:
|
|
||||||
- $TRAVIS_BUILD_DIR/.cache
|
|
||||||
- $TRAVIS_BUILD_DIR/node_modules
|
|
||||||
before_install:
|
|
||||||
- sudo sed -i 's/mozilla\/DST_Root_CA_X3.crt/!mozilla\/DST_Root_CA_X3.crt/g' /etc/ca-certificates.conf
|
|
||||||
- sudo update-ca-certificates -f
|
|
||||||
|
|
||||||
# https://gist.github.com/iedemam/9830045
|
|
||||||
- sed -i 's/git@github.com:/https:\/\/github.com\//' .gitmodules
|
|
||||||
- git submodule update --init --recursive
|
|
||||||
|
|
||||||
- $SHELL --version 2> /dev/null || dpkg -s $SHELL 2> /dev/null || which $SHELL
|
|
||||||
- curl --version
|
|
||||||
- wget --version
|
|
||||||
- bash --version | head
|
|
||||||
- zsh --version
|
|
||||||
- dpkg -s dash | grep ^Version | awk '{print $2}'
|
|
||||||
# install python
|
|
||||||
- pyenv local 2.7.18 || pyenv install 2.7.18
|
|
||||||
- pyenv local 2.7.18 || echo 'pyenv failed'
|
|
||||||
- python -V
|
|
||||||
install:
|
|
||||||
- if [ -z "${SHELLCHECK-}" ]; then nvm install 16 && nvm unalias default && npm install && npm prune && npm ls urchin doctoc eclint dockerfile_lint; fi
|
|
||||||
- '[ -z "$WITHOUT_CURL" ] || sudo apt-get remove curl -y'
|
|
||||||
script:
|
|
||||||
- if [ -n "${SHELL-}" ] && [ -n "${TEST_SUITE}" ]; then if [ "${TEST_SUITE}" = 'installation_iojs' ] || [ "${TEST_SUITE}" = 'xenial' ]; then travis_retry make TEST_SUITE=$TEST_SUITE URCHIN="$(npm bin)/urchin" test-$SHELL ; else make TEST_SUITE=$TEST_SUITE URCHIN="$(npm bin)/urchin" test-$SHELL; fi; fi
|
|
||||||
before_cache:
|
|
||||||
- if [ -n "$WITHOUT_CURL" ]; then sudo apt-get install curl -y ; fi
|
|
||||||
jobs:
|
|
||||||
include:
|
|
||||||
- env: SHELL=bash TEST_SUITE=installation_node
|
|
||||||
dist: xenial
|
|
||||||
- env: SHELL=bash TEST_SUITE=installation_node WITHOUT_CURL=1
|
|
||||||
dist: xenial
|
|
||||||
- env: SHELL=sh TEST_SUITE=installation_node
|
|
||||||
dist: xenial
|
|
||||||
- env: SHELL=sh TEST_SUITE=installation_node WITHOUT_CURL=1
|
|
||||||
dist: xenial
|
|
||||||
- env: SHELL=dash TEST_SUITE=installation_node
|
|
||||||
dist: xenial
|
|
||||||
- env: SHELL=dash TEST_SUITE=installation_node WITHOUT_CURL=1
|
|
||||||
dist: xenial
|
|
||||||
- env: SHELL=zsh TEST_SUITE=installation_node
|
|
||||||
dist: xenial
|
|
||||||
- env: SHELL=zsh TEST_SUITE=installation_node WITHOUT_CURL=1
|
|
||||||
dist: xenial
|
|
||||||
#- env: SHELL=ksh TEST_SUITE=installation_node
|
|
||||||
# dist: xenial
|
|
||||||
#- env: SHELL=ksh TEST_SUITE=installation_node WITHOUT_CURL=1
|
|
||||||
# dist: xenial
|
|
||||||
- env: SHELL=bash TEST_SUITE=xenial
|
|
||||||
dist: xenial
|
|
||||||
- env: SHELL=sh TEST_SUITE=xenial
|
|
||||||
dist: xenial
|
|
||||||
- env: SHELL=dash TEST_SUITE=xenial
|
|
||||||
dist: xenial
|
|
||||||
- env: SHELL=zsh TEST_SUITE=xenial
|
|
||||||
dist: xenial
|
|
||||||
#- env: SHELL=ksh TEST_SUITE=xenial
|
|
||||||
# dist: xenial
|
|
||||||
env:
|
|
||||||
global:
|
|
||||||
- CXX=g++
|
|
||||||
- CC=gcc
|
|
||||||
- PATH="$(echo $PATH | sed 's/::/:/')"
|
|
||||||
- PATH="/usr/lib/ccache/:$PATH"
|
|
||||||
- NVM_DIR="${TRAVIS_BUILD_DIR}"
|
|
||||||
matrix:
|
|
||||||
- SHELL=sh TEST_SUITE=fast
|
|
||||||
- SHELL=dash TEST_SUITE=fast
|
|
||||||
- SHELL=bash TEST_SUITE=fast
|
|
||||||
- SHELL=zsh TEST_SUITE=fast
|
|
||||||
# - SHELL=ksh TEST_SUITE=fast
|
|
||||||
- SHELL=sh TEST_SUITE=installation_iojs WITHOUT_CURL=1
|
|
||||||
- SHELL=dash TEST_SUITE=installation_iojs WITHOUT_CURL=1
|
|
||||||
- SHELL=bash TEST_SUITE=installation_iojs WITHOUT_CURL=1
|
|
||||||
- SHELL=zsh TEST_SUITE=installation_iojs WITHOUT_CURL=1
|
|
||||||
# - SHELL=ksh TEST_SUITE=installation_iojs WITHOUT_CURL=1
|
|
||||||
@@ -443,7 +443,7 @@ Node has a [schedule](https://github.com/nodejs/Release#release-schedule) for lo
|
|||||||
|
|
||||||
Any time your local copy of `nvm` connects to https://nodejs.org, it will re-create the appropriate local aliases for all available LTS lines. These aliases (stored under `$NVM_DIR/alias/lts`), are managed by `nvm`, and you should not modify, remove, or create these files - expect your changes to be undone, and expect meddling with these files to cause bugs that will likely not be supported.
|
Any time your local copy of `nvm` connects to https://nodejs.org, it will re-create the appropriate local aliases for all available LTS lines. These aliases (stored under `$NVM_DIR/alias/lts`), are managed by `nvm`, and you should not modify, remove, or create these files - expect your changes to be undone, and expect meddling with these files to cause bugs that will likely not be supported.
|
||||||
|
|
||||||
To get the latest LTS version of node and migrate your existing installed packages, use
|
To get the latest LTS version of node and migrate your existing installed packages, use:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
nvm install --reinstall-packages-from=current 'lts/*'
|
nvm install --reinstall-packages-from=current 'lts/*'
|
||||||
@@ -496,7 +496,10 @@ stevemao/left-pad
|
|||||||
|
|
||||||
### io.js
|
### io.js
|
||||||
|
|
||||||
If you want to install [io.js](https://github.com/iojs/io.js/):
|
> [!WARNING]
|
||||||
|
> io.js was a [fork of Node.js](https://en.wikipedia.org/wiki/Node.js#History), created in 2014 and merged back in 2015. io.js shipped v1, v2, and v3 release lines; post-merge, node.js began releasing with v4.
|
||||||
|
|
||||||
|
If you want to install io.js:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
nvm install iojs
|
nvm install iojs
|
||||||
@@ -1040,7 +1043,7 @@ To change the user directory and/or account name follow the instructions [here](
|
|||||||
[Urchin]: https://git.sdf.org/tlevine/urchin
|
[Urchin]: https://git.sdf.org/tlevine/urchin
|
||||||
[Fish]: https://fishshell.com
|
[Fish]: https://fishshell.com
|
||||||
|
|
||||||
**Homebrew makes zsh directories unsecure**
|
**Homebrew makes zsh directories insecure**
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
zsh compinit: insecure directories, run compaudit for list.
|
zsh compinit: insecure directories, run compaudit for list.
|
||||||
|
|||||||
@@ -428,7 +428,10 @@ nvm_do_install() {
|
|||||||
COMPLETION_STR='[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion\n'
|
COMPLETION_STR='[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion\n'
|
||||||
BASH_OR_ZSH=false
|
BASH_OR_ZSH=false
|
||||||
|
|
||||||
if [ -z "${NVM_PROFILE-}" ] ; then
|
if [ "${PROFILE-}" = '/dev/null' ] ; then
|
||||||
|
# the user has specifically requested NOT to have nvm touch their profile
|
||||||
|
echo
|
||||||
|
elif [ -z "${NVM_PROFILE-}" ] ; then
|
||||||
local TRIED_PROFILE
|
local TRIED_PROFILE
|
||||||
if [ -n "${PROFILE}" ]; then
|
if [ -n "${PROFILE}" ]; then
|
||||||
TRIED_PROFILE="${NVM_PROFILE} (as defined in \$PROFILE), "
|
TRIED_PROFILE="${NVM_PROFILE} (as defined in \$PROFILE), "
|
||||||
|
|||||||
9
nvm-exec
9
nvm-exec
@@ -9,9 +9,12 @@ unset NVM_CD_FLAGS
|
|||||||
|
|
||||||
if [ -n "$NODE_VERSION" ]; then
|
if [ -n "$NODE_VERSION" ]; then
|
||||||
nvm use "$NODE_VERSION" > /dev/null || exit 127
|
nvm use "$NODE_VERSION" > /dev/null || exit 127
|
||||||
elif ! nvm use >/dev/null 2>&1; then
|
else
|
||||||
echo "No NODE_VERSION provided; no .nvmrc file found" >&2
|
nvm_rc_version > /dev/null && nvm_ensure_version_installed "$NVM_RC_VERSION";
|
||||||
exit 127
|
if ! nvm use >/dev/null 2>&1; then
|
||||||
|
echo "No NODE_VERSION provided; no .nvmrc file found" >&2
|
||||||
|
exit 127
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec "$@"
|
exec "$@"
|
||||||
|
|||||||
27
nvm.sh
27
nvm.sh
@@ -781,6 +781,15 @@ nvm_remote_version() {
|
|||||||
else
|
else
|
||||||
VERSION="$(NVM_LTS="${NVM_LTS-}" nvm_remote_versions "${PATTERN}" | command tail -1)"
|
VERSION="$(NVM_LTS="${NVM_LTS-}" nvm_remote_versions "${PATTERN}" | command tail -1)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${PATTERN}" ] && [ "_${VERSION}" != "_N/A" ] && ! nvm_validate_implicit_alias "${PATTERN}" 2>/dev/null; then
|
||||||
|
local VERSION_NUM
|
||||||
|
VERSION_NUM="$(nvm_echo "${VERSION}" | command awk '{print $1}')"
|
||||||
|
if ! nvm_echo "${VERSION_NUM}" | nvm_grep -q "${PATTERN}"; then
|
||||||
|
VERSION='N/A'
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -n "${NVM_VERSION_ONLY-}" ]; then
|
if [ -n "${NVM_VERSION_ONLY-}" ]; then
|
||||||
command awk 'BEGIN {
|
command awk 'BEGIN {
|
||||||
n = split(ARGV[1], a);
|
n = split(ARGV[1], a);
|
||||||
@@ -2633,18 +2642,24 @@ nvm_install_source() {
|
|||||||
NVM_OS="$(nvm_get_os)"
|
NVM_OS="$(nvm_get_os)"
|
||||||
|
|
||||||
local make
|
local make
|
||||||
make='make'
|
|
||||||
local MAKE_CXX
|
local MAKE_CXX
|
||||||
|
# For old Node.js versions (< 0.12), explicitly set SHELL=/bin/sh to avoid
|
||||||
|
# issues with zsh's strict glob handling in Makefiles with unquoted globs
|
||||||
|
local MAKE_SHELL_OVERRIDE
|
||||||
|
if nvm_version_greater "0.12.0" "${VERSION}"; then
|
||||||
|
MAKE_SHELL_OVERRIDE=' SHELL=/bin/sh'
|
||||||
|
fi
|
||||||
|
make="make${MAKE_SHELL_OVERRIDE-}"
|
||||||
case "${NVM_OS}" in
|
case "${NVM_OS}" in
|
||||||
'freebsd' | 'openbsd')
|
'freebsd' | 'openbsd')
|
||||||
make='gmake'
|
make="gmake${MAKE_SHELL_OVERRIDE-}"
|
||||||
MAKE_CXX="CC=${CC:-cc} CXX=${CXX:-c++}"
|
MAKE_CXX="CC=${CC:-cc} CXX=${CXX:-c++}"
|
||||||
;;
|
;;
|
||||||
'darwin')
|
'darwin')
|
||||||
MAKE_CXX="CC=${CC:-cc} CXX=${CXX:-c++}"
|
MAKE_CXX="CC=${CC:-cc} CXX=${CXX:-c++}"
|
||||||
;;
|
;;
|
||||||
'aix')
|
'aix')
|
||||||
make='gmake'
|
make="gmake${MAKE_SHELL_OVERRIDE-}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
if nvm_has "clang++" && nvm_has "clang" && nvm_version_greater_than_or_equal_to "$(nvm_clang_version)" 3.5; then
|
if nvm_has "clang++" && nvm_has "clang" && nvm_version_greater_than_or_equal_to "$(nvm_clang_version)" 3.5; then
|
||||||
@@ -4515,9 +4530,9 @@ nvm_get_default_packages() {
|
|||||||
NVM_DEFAULT_PACKAGE_FILE="${NVM_DIR}/default-packages"
|
NVM_DEFAULT_PACKAGE_FILE="${NVM_DIR}/default-packages"
|
||||||
if [ -f "${NVM_DEFAULT_PACKAGE_FILE}" ]; then
|
if [ -f "${NVM_DEFAULT_PACKAGE_FILE}" ]; then
|
||||||
command awk -v filename="${NVM_DEFAULT_PACKAGE_FILE}" '
|
command awk -v filename="${NVM_DEFAULT_PACKAGE_FILE}" '
|
||||||
/^[[:space:]]*#/ { next } # Skip lines that begin with #
|
/^[ \t]*#/ { next } # Skip lines that begin with #
|
||||||
/^[[:space:]]*$/ { next } # Skip empty lines
|
/^[ \t]*$/ { next } # Skip empty lines
|
||||||
/[[:space:]]/ && !/^[[:space:]]*#/ {
|
/[ \t]/ && !/^[ \t]*#/ {
|
||||||
print "Only one package per line is allowed in `" filename "`. Please remove any lines with multiple space-separated values." > "/dev/stderr"
|
print "Only one package per line is allowed in `" filename "`. Please remove any lines with multiple space-separated values." > "/dev/stderr"
|
||||||
err = 1
|
err = 1
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
20
test/fast/Running 'nvm-exec' should display required node version
Executable file
20
test/fast/Running 'nvm-exec' should display required node version
Executable file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -x
|
||||||
|
\. ../../nvm.sh
|
||||||
|
|
||||||
|
die () { echo "$@" ; rm .nvmrc ; exit 1; }
|
||||||
|
|
||||||
|
NVM_TEST_VERSION=v0.42
|
||||||
|
|
||||||
|
# Write it to nvmrc
|
||||||
|
echo "$NVM_TEST_VERSION" > .nvmrc
|
||||||
|
|
||||||
|
OUTPUT="$(../../nvm-exec 2>&1)";
|
||||||
|
EXPECTED="N/A: version \"${NVM_TEST_VERSION}\" is not yet installed.
|
||||||
|
|
||||||
|
You need to run \`nvm install ${NVM_TEST_VERSION}\` to install and use it.
|
||||||
|
No NODE_VERSION provided; no .nvmrc file found";
|
||||||
|
|
||||||
|
# Skip install, we want to test the error message
|
||||||
|
[ "${EXPECTED}" = "${OUTPUT}" ] || die "expected >${EXPECTED}<, got >${OUTPUT}<"
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
\. ../../../nvm.sh
|
\. ../../../nvm.sh
|
||||||
|
|
||||||
set -e
|
#set -e #nvm use system returns 127 and No system set message
|
||||||
|
|
||||||
die () {
|
die () {
|
||||||
# echo "$@" ;
|
# echo "$@" ;
|
||||||
@@ -24,7 +24,7 @@ fi
|
|||||||
# default system color
|
# default system color
|
||||||
nvm use system
|
nvm use system
|
||||||
OUTPUT=$(nvm_print_versions system)
|
OUTPUT=$(nvm_print_versions system)
|
||||||
FORMAT="\033[0;32m-> %12s\033[0m"
|
FORMAT="\033[0;33m%15s\033[0m"
|
||||||
VERSION='system'
|
VERSION='system'
|
||||||
EXPECTED_OUTPUT=$(command printf -- "${FORMAT}\\n" "${VERSION}")
|
EXPECTED_OUTPUT=$(command printf -- "${FORMAT}\\n" "${VERSION}")
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ nvm_ls_current() { echo "current";}
|
|||||||
|
|
||||||
# default current color
|
# default current color
|
||||||
OUTPUT=$(nvm_print_versions current)
|
OUTPUT=$(nvm_print_versions current)
|
||||||
FORMAT="\033[0;32m-> %12s\033[0m"
|
FORMAT="\033[0;32m->%13s\033[0m"
|
||||||
VERSION="current"
|
VERSION="current"
|
||||||
EXPECTED_OUTPUT=$(command printf -- "${FORMAT}\\n" "${VERSION}")
|
EXPECTED_OUTPUT=$(command printf -- "${FORMAT}\\n" "${VERSION}")
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ EXPECTED_OUTPUT=$(command printf -- "${FORMAT}\\n" "${VERSION}")
|
|||||||
# custom current color
|
# custom current color
|
||||||
nvm set-colors YCMGR
|
nvm set-colors YCMGR
|
||||||
OUTPUT=$(nvm_print_versions current)
|
OUTPUT=$(nvm_print_versions current)
|
||||||
FORMAT="\033[1;35m-> %12s\033[0m"
|
FORMAT="\033[1;35m->%13s\033[0m"
|
||||||
VERSION="current"
|
VERSION="current"
|
||||||
EXPECTED_OUTPUT=$(command printf -- "${FORMAT}\\n" "${VERSION}")
|
EXPECTED_OUTPUT=$(command printf -- "${FORMAT}\\n" "${VERSION}")
|
||||||
|
|
||||||
|
|||||||
57
test/fast/Unit tests/nvm_get_default_packages mawk compat
Executable file
57
test/fast/Unit tests/nvm_get_default_packages mawk compat
Executable file
@@ -0,0 +1,57 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Test that nvm_get_default_packages awk patterns work with mawk
|
||||||
|
# This test runs with mawk explicitly if available, to catch POSIX
|
||||||
|
# character class compatibility issues (mawk doesn't support [[:space:]])
|
||||||
|
|
||||||
|
die () { echo "$@" ; cleanup ; exit 1; }
|
||||||
|
|
||||||
|
\. ../../../nvm.sh
|
||||||
|
|
||||||
|
# The awk command from nvm_get_default_packages
|
||||||
|
AWK_SCRIPT='
|
||||||
|
/^[ \t]*#/ { next }
|
||||||
|
/^[ \t]*$/ { next }
|
||||||
|
/[ \t]/ && !/^[ \t]*#/ {
|
||||||
|
print "error" > "/dev/stderr"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
{
|
||||||
|
if (NR > 1 && !prev_space) printf " "
|
||||||
|
printf "%s", $0
|
||||||
|
prev_space = 0
|
||||||
|
}
|
||||||
|
'
|
||||||
|
|
||||||
|
TEST_INPUT="rimraf
|
||||||
|
object-inspect@1.0.2
|
||||||
|
|
||||||
|
# commented-package
|
||||||
|
|
||||||
|
stevemao/left-pad"
|
||||||
|
|
||||||
|
EXPECTED_OUTPUT="rimraf object-inspect@1.0.2 stevemao/left-pad"
|
||||||
|
|
||||||
|
# Test with system awk
|
||||||
|
OUTPUT="$(printf '%s\n' "${TEST_INPUT}" | awk "${AWK_SCRIPT}")"
|
||||||
|
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "system awk: expected >${EXPECTED_OUTPUT}<, got >${OUTPUT}<"
|
||||||
|
|
||||||
|
# Test with mawk explicitly if available
|
||||||
|
if command -v mawk > /dev/null 2>&1; then
|
||||||
|
OUTPUT="$(printf '%s\n' "${TEST_INPUT}" | mawk "${AWK_SCRIPT}")"
|
||||||
|
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "mawk: expected >${EXPECTED_OUTPUT}<, got >${OUTPUT}<"
|
||||||
|
echo "mawk test passed"
|
||||||
|
else
|
||||||
|
echo "mawk not available, skipping mawk-specific test"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Test with gawk explicitly if available
|
||||||
|
if command -v gawk > /dev/null 2>&1; then
|
||||||
|
OUTPUT="$(printf '%s\n' "${TEST_INPUT}" | gawk "${AWK_SCRIPT}")"
|
||||||
|
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "gawk: expected >${EXPECTED_OUTPUT}<, got >${OUTPUT}<"
|
||||||
|
echo "gawk test passed"
|
||||||
|
else
|
||||||
|
echo "gawk not available, skipping gawk-specific test"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "All awk compatibility tests passed"
|
||||||
91
test/fast/Unit tests/nvm_install_source SHELL override
Executable file
91
test/fast/Unit tests/nvm_install_source SHELL override
Executable file
@@ -0,0 +1,91 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cleanup () {
|
||||||
|
unset -f make gmake nvm_download nvm_get_os nvm_get_arch nvm_extract_tarball nvm_version_path nvm_get_make_jobs
|
||||||
|
rm -rf "${FAKE_TMPDIR-}"
|
||||||
|
}
|
||||||
|
die () { echo "$@" ; cleanup ; exit 1; }
|
||||||
|
|
||||||
|
\. ../../../nvm.sh
|
||||||
|
|
||||||
|
# Create a fake directory structure for the build
|
||||||
|
FAKE_TMPDIR="$(mktemp -d)"
|
||||||
|
mkdir -p "${FAKE_TMPDIR}/files"
|
||||||
|
touch "${FAKE_TMPDIR}/node-old.tar.gz"
|
||||||
|
touch "${FAKE_TMPDIR}/node-new.tar.gz"
|
||||||
|
|
||||||
|
# Track make invocations
|
||||||
|
MAKE_CALLS=""
|
||||||
|
|
||||||
|
make() {
|
||||||
|
MAKE_CALLS="${MAKE_CALLS}make $*
|
||||||
|
"
|
||||||
|
return 1 # Fail to prevent actual build
|
||||||
|
}
|
||||||
|
|
||||||
|
gmake() {
|
||||||
|
MAKE_CALLS="${MAKE_CALLS}gmake $*
|
||||||
|
"
|
||||||
|
return 1 # Fail to prevent actual build
|
||||||
|
}
|
||||||
|
|
||||||
|
nvm_download() {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
nvm_get_arch() {
|
||||||
|
echo "x64"
|
||||||
|
}
|
||||||
|
|
||||||
|
nvm_extract_tarball() {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
nvm_version_path() {
|
||||||
|
echo "${FAKE_TMPDIR}/versions/${1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
nvm_get_make_jobs() {
|
||||||
|
NVM_MAKE_JOBS=1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Test 1: Old version (0.6.21) should have SHELL=/bin/sh
|
||||||
|
MAKE_CALLS=""
|
||||||
|
NVM_DIR="${FAKE_TMPDIR}"
|
||||||
|
export NVM_DIR
|
||||||
|
|
||||||
|
# Manually test the version check logic
|
||||||
|
if nvm_version_greater "0.12.0" "0.6.21"; then
|
||||||
|
OLD_VERSION_DETECTED="yes"
|
||||||
|
else
|
||||||
|
OLD_VERSION_DETECTED="no"
|
||||||
|
fi
|
||||||
|
[ "${OLD_VERSION_DETECTED}" = "yes" ] || die "Expected 0.6.21 to be detected as old version"
|
||||||
|
|
||||||
|
# Test 2: New version (0.12.0) should NOT have SHELL=/bin/sh
|
||||||
|
if nvm_version_greater "0.12.0" "0.12.0"; then
|
||||||
|
NEW_VERSION_DETECTED="yes"
|
||||||
|
else
|
||||||
|
NEW_VERSION_DETECTED="no"
|
||||||
|
fi
|
||||||
|
[ "${NEW_VERSION_DETECTED}" = "no" ] || die "Expected 0.12.0 to NOT be detected as old version"
|
||||||
|
|
||||||
|
# Test 3: Newer version (14.0.0) should NOT have SHELL=/bin/sh
|
||||||
|
if nvm_version_greater "0.12.0" "14.0.0"; then
|
||||||
|
NEWER_VERSION_DETECTED="yes"
|
||||||
|
else
|
||||||
|
NEWER_VERSION_DETECTED="no"
|
||||||
|
fi
|
||||||
|
[ "${NEWER_VERSION_DETECTED}" = "no" ] || die "Expected 14.0.0 to NOT be detected as old version"
|
||||||
|
|
||||||
|
# Test 4: Edge case version (0.11.99) should have SHELL=/bin/sh
|
||||||
|
if nvm_version_greater "0.12.0" "0.11.99"; then
|
||||||
|
EDGE_VERSION_DETECTED="yes"
|
||||||
|
else
|
||||||
|
EDGE_VERSION_DETECTED="no"
|
||||||
|
fi
|
||||||
|
[ "${EDGE_VERSION_DETECTED}" = "yes" ] || die "Expected 0.11.99 to be detected as old version"
|
||||||
|
|
||||||
|
echo "All nvm_install_source SHELL override tests passed"
|
||||||
|
|
||||||
|
cleanup
|
||||||
@@ -31,7 +31,7 @@ check_version() {
|
|||||||
mkdir -p "$NODE_PATH/$VERSION/bin" && cd "$NODE_PATH/$VERSION/bin" && touch "$NODE_PATH/$VERSION/bin/$BINARY"
|
mkdir -p "$NODE_PATH/$VERSION/bin" && cd "$NODE_PATH/$VERSION/bin" && touch "$NODE_PATH/$VERSION/bin/$BINARY"
|
||||||
! nvm_is_version_installed "$VERSION" || die "nvm_is_version_installed $VERSION should fail with non executable existing version"
|
! nvm_is_version_installed "$VERSION" || die "nvm_is_version_installed $VERSION should fail with non executable existing version"
|
||||||
|
|
||||||
# nvm_is_version_installed whould work
|
# nvm_is_version_installed would work
|
||||||
chmod +x "$NODE_PATH/$VERSION/bin/$BINARY"
|
chmod +x "$NODE_PATH/$VERSION/bin/$BINARY"
|
||||||
nvm_is_version_installed "$VERSION" || die "nvm_is_version_installed $VERSION should work"
|
nvm_is_version_installed "$VERSION" || die "nvm_is_version_installed $VERSION should work"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,4 +75,24 @@ EXIT_CODE="$(nvm_remote_version node >/dev/null 2>&1 ; echo $?)"
|
|||||||
|| die "nvm_remote_version node did not return contents of nvm_ls_remote node; got $OUTPUT"
|
|| die "nvm_remote_version node did not return contents of nvm_ls_remote node; got $OUTPUT"
|
||||||
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version node did not exit with 0, got $EXIT_CODE"
|
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version node did not exit with 0, got $EXIT_CODE"
|
||||||
|
|
||||||
|
# Test LTS name rejection (Issue #3474)
|
||||||
|
# When nvm_remote_versions returns a line with LTS name in description,
|
||||||
|
# nvm_remote_version should reject it if the pattern doesn't match the version number
|
||||||
|
|
||||||
|
nvm_remote_versions() {
|
||||||
|
echo "v4.9.1 Argon *"
|
||||||
|
}
|
||||||
|
OUTPUT="$(nvm_remote_version Argon)"
|
||||||
|
EXIT_CODE="$(nvm_remote_version Argon >/dev/null 2>&1 ; echo $?)"
|
||||||
|
[ "_$OUTPUT" = "_N/A" ] || die "nvm_remote_version Argon should return N/A (LTS name not in version), got $OUTPUT"
|
||||||
|
[ "_$EXIT_CODE" = "_3" ] || die "nvm_remote_version Argon should exit with code 3, got $EXIT_CODE"
|
||||||
|
|
||||||
|
nvm_remote_versions() {
|
||||||
|
echo "v4.9.1"
|
||||||
|
}
|
||||||
|
OUTPUT="$(nvm_remote_version 4)"
|
||||||
|
EXIT_CODE="$(nvm_remote_version 4 >/dev/null 2>&1 ; echo $?)"
|
||||||
|
[ "_$OUTPUT" = "_v4.9.1" ] || die "nvm_remote_version 4 should return v4.9.1, got $OUTPUT"
|
||||||
|
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version 4 should exit with code 0, got $EXIT_CODE"
|
||||||
|
|
||||||
cleanup
|
cleanup
|
||||||
|
|||||||
62
test/install_script/nvm_install_profile_skip
Executable file
62
test/install_script/nvm_install_profile_skip
Executable file
@@ -0,0 +1,62 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo "$@" ; cleanup ; exit 1; }
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
unset -f install_nvm_from_git install_nvm_as_script nvm_detect_profile nvm_has
|
||||||
|
unset -f setup cleanup die
|
||||||
|
unset NVM_ENV METHOD PROFILE
|
||||||
|
}
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
NVM_ENV=testing \. ../../install.sh
|
||||||
|
|
||||||
|
# Mock installation functions to do nothing
|
||||||
|
install_nvm_from_git() { :; }
|
||||||
|
install_nvm_as_script() { :; }
|
||||||
|
|
||||||
|
# Mock nvm_has to return true for git (to take the git path)
|
||||||
|
nvm_has() {
|
||||||
|
case "$1" in
|
||||||
|
git) return 0 ;;
|
||||||
|
xcode-select) return 1 ;;
|
||||||
|
*) return 1 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# Mock nvm_detect_profile to return empty (no profile found)
|
||||||
|
nvm_detect_profile() {
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setup
|
||||||
|
|
||||||
|
#
|
||||||
|
# Test: When PROFILE="/dev/null", no "Profile not found" warning should appear
|
||||||
|
#
|
||||||
|
|
||||||
|
OUTPUT="$(PROFILE='/dev/null' METHOD='' NVM_DIR="$(mktemp -d)" nvm_do_install 2>&1)"
|
||||||
|
if echo "$OUTPUT" | grep -q "Profile not found"; then
|
||||||
|
die "nvm_do_install should NOT show 'Profile not found' when PROFILE=/dev/null, got: $OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# Test: When PROFILE is empty/unset, the "Profile not found" warning SHOULD appear
|
||||||
|
#
|
||||||
|
|
||||||
|
OUTPUT="$(PROFILE='' METHOD='' NVM_DIR="$(mktemp -d)" nvm_do_install 2>&1)"
|
||||||
|
if ! echo "$OUTPUT" | grep -q "Profile not found"; then
|
||||||
|
die "nvm_do_install should show 'Profile not found' when PROFILE is empty, got: $OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# Test: When PROFILE points to a non-existent file, the "Profile not found" warning SHOULD appear
|
||||||
|
#
|
||||||
|
|
||||||
|
OUTPUT="$(PROFILE='/nonexistent/profile' METHOD='' NVM_DIR="$(mktemp -d)" nvm_do_install 2>&1)"
|
||||||
|
if ! echo "$OUTPUT" | grep -q "Profile not found"; then
|
||||||
|
die "nvm_do_install should show 'Profile not found' when PROFILE points to nonexistent file, got: $OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cleanup
|
||||||
@@ -43,6 +43,13 @@ nvm_install_source() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Override nvm_get_make_jobs to produce predictable output regardless of actual CPU count
|
||||||
|
nvm_get_make_jobs() {
|
||||||
|
NVM_MAKE_JOBS=1
|
||||||
|
nvm_echo "Detected that you have 2 CPU core(s)"
|
||||||
|
nvm_echo 'Number of CPU core(s) less than or equal to 2, running in single-threaded mode'
|
||||||
|
}
|
||||||
|
|
||||||
# binary fails, falls back to source if -b is not set
|
# binary fails, falls back to source if -b is not set
|
||||||
OUTPUT="$(nvm install 9.0.0 2>&1)"
|
OUTPUT="$(nvm install 9.0.0 2>&1)"
|
||||||
EXPECTED_OUTPUT="binary failed
|
EXPECTED_OUTPUT="binary failed
|
||||||
|
|||||||
Reference in New Issue
Block a user