mirror of
https://github.com/nvm-sh/nvm.git
synced 2026-02-07 02:12:49 +08:00
Compare commits
8 Commits
fix-nvmrc-
...
548fcc1057
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
548fcc1057 | ||
|
|
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)
|
||||||
|
|||||||
95
.github/workflows/tests-fast.yml
vendored
Normal file
95
.github/workflows/tests-fast.yml
vendored
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
name: 'Tests: fast'
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
fast:
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
name: 'fast (${{ 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
|
||||||
|
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 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: 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
|
||||||
107
.github/workflows/tests-installation-node.yml
vendored
Normal file
107
.github/workflows/tests-installation-node.yml
vendored
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
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 "SHELL=${{ matrix.shell }}" \
|
||||||
|
-e "NVM_DIR=/workspace" \
|
||||||
|
-e "TERM=xterm-256color" \
|
||||||
|
-e "DEBIAN_FRONTEND=noninteractive" \
|
||||||
|
-e "WITHOUT_CURL=${{ matrix.without_curl }}" \
|
||||||
|
ubuntu:16.04 \
|
||||||
|
bash -c '
|
||||||
|
set -ex
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y git curl wget make build-essential python zsh libssl-dev
|
||||||
|
if [ "${{ matrix.shell }}" != "sh" ] && [ "${{ matrix.shell }}" != "bash" ]; then
|
||||||
|
apt-get install -y ${{ matrix.shell }} || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use nvm to install Node.js for running urchin
|
||||||
|
# Node 16 is the last version supporting GLIBC 2.27 (Ubuntu 18.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 unset nvm stuff for the actual tests
|
||||||
|
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" ":")"
|
||||||
|
|
||||||
|
make TEST_SUITE="installation_node" SHELL="${{ matrix.shell }}" URCHIN="$URCHIN_PATH" test-${{ matrix.shell }}
|
||||||
|
'
|
||||||
|
|
||||||
|
all:
|
||||||
|
permissions:
|
||||||
|
contents: none
|
||||||
|
name: 'all installation_node tests'
|
||||||
|
needs: [installation_node]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- run: true
|
||||||
97
.github/workflows/tests-xenial.yml
vendored
Normal file
97
.github/workflows/tests-xenial.yml
vendored
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
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 "SHELL=${{ matrix.shell }}" \
|
||||||
|
-e "NVM_DIR=/workspace" \
|
||||||
|
-e "TERM=xterm-256color" \
|
||||||
|
-e "DEBIAN_FRONTEND=noninteractive" \
|
||||||
|
ubuntu:16.04 \
|
||||||
|
bash -c '
|
||||||
|
set -ex
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y git curl wget make build-essential python zsh libssl-dev
|
||||||
|
if [ "${{ matrix.shell }}" != "sh" ] && [ "${{ matrix.shell }}" != "bash" ]; then
|
||||||
|
apt-get install -y ${{ matrix.shell }} || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use nvm to install Node.js for running urchin
|
||||||
|
# Node 16 is the last version supporting GLIBC 2.27 (Ubuntu 18.04)
|
||||||
|
export NVM_DIR="/workspace"
|
||||||
|
. /workspace/nvm.sh
|
||||||
|
nvm install 16
|
||||||
|
nvm use 16
|
||||||
|
|
||||||
|
npm ls urchin
|
||||||
|
URCHIN_PATH="$(npx which urchin)"
|
||||||
|
|
||||||
|
# Now unset nvm stuff for the actual tests
|
||||||
|
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" ":")"
|
||||||
|
|
||||||
|
make TEST_SUITE="xenial" SHELL="${{ matrix.shell }}" URCHIN="$URCHIN_PATH" test-${{ matrix.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 "$@"
|
||||||
|
|||||||
33
nvm.sh
33
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);
|
||||||
@@ -2779,11 +2788,15 @@ nvm_die_on_prefix() {
|
|||||||
# npm first looks at $PREFIX (case-sensitive)
|
# npm first looks at $PREFIX (case-sensitive)
|
||||||
# we do not bother to test the value here; if this env var is set, unset it to continue.
|
# we do not bother to test the value here; if this env var is set, unset it to continue.
|
||||||
# however, `npm exec` in npm v7.2+ sets $PREFIX; if set, inherit it
|
# however, `npm exec` in npm v7.2+ sets $PREFIX; if set, inherit it
|
||||||
if [ -n "${PREFIX-}" ] && [ "$(nvm_version_path "$(node -v)")" != "${PREFIX}" ]; then
|
if [ -n "${PREFIX-}" ]; then
|
||||||
nvm deactivate >/dev/null 2>&1
|
local NVM_NODE_VERSION
|
||||||
nvm_err "nvm is not compatible with the \"PREFIX\" environment variable: currently set to \"${PREFIX}\""
|
NVM_NODE_VERSION="$(node -v 2>/dev/null)"
|
||||||
nvm_err 'Run `unset PREFIX` to unset it.'
|
if [ -z "${NVM_NODE_VERSION}" ] || [ "$(nvm_version_path "${NVM_NODE_VERSION}" 2>/dev/null)" != "${PREFIX}" ]; then
|
||||||
return 3
|
nvm deactivate >/dev/null 2>&1
|
||||||
|
nvm_err "nvm is not compatible with the \"PREFIX\" environment variable: currently set to \"${PREFIX}\""
|
||||||
|
nvm_err 'Run `unset PREFIX` to unset it.'
|
||||||
|
return 3
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local NVM_OS
|
local NVM_OS
|
||||||
@@ -4615,24 +4628,24 @@ nvm_auto() {
|
|||||||
VERSION="$(nvm_resolve_local_alias default 2>/dev/null || nvm_echo)"
|
VERSION="$(nvm_resolve_local_alias default 2>/dev/null || nvm_echo)"
|
||||||
if [ -n "${VERSION}" ]; then
|
if [ -n "${VERSION}" ]; then
|
||||||
if [ "_${VERSION}" != '_N/A' ] && nvm_is_valid_version "${VERSION}"; then
|
if [ "_${VERSION}" != '_N/A' ] && nvm_is_valid_version "${VERSION}"; then
|
||||||
nvm use --silent "${VERSION}" >/dev/null
|
nvm use --silent "${VERSION}" >/dev/null || :
|
||||||
else
|
else
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
elif nvm_rc_version >/dev/null 2>&1; then
|
elif nvm_rc_version >/dev/null 2>&1; then
|
||||||
nvm use --silent >/dev/null
|
nvm use --silent >/dev/null || :
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
nvm use --silent "${NVM_CURRENT}" >/dev/null
|
nvm use --silent "${NVM_CURRENT}" >/dev/null || :
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
install)
|
install)
|
||||||
local VERSION
|
local VERSION
|
||||||
VERSION="$(nvm_alias default 2>/dev/null || nvm_echo)"
|
VERSION="$(nvm_alias default 2>/dev/null || nvm_echo)"
|
||||||
if [ -n "${VERSION}" ] && [ "_${VERSION}" != '_N/A' ] && nvm_is_valid_version "${VERSION}"; then
|
if [ -n "${VERSION}" ] && [ "_${VERSION}" != '_N/A' ] && nvm_is_valid_version "${VERSION}"; then
|
||||||
nvm install "${VERSION}" >/dev/null
|
nvm install "${VERSION}" >/dev/null || :
|
||||||
elif nvm_rc_version >/dev/null 2>&1; then
|
elif nvm_rc_version >/dev/null 2>&1; then
|
||||||
nvm install >/dev/null
|
nvm install >/dev/null || :
|
||||||
else
|
else
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|||||||
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}")
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
die () { echo "$@" ; cleanup ; exit 1; }
|
die () { echo "$@" ; cleanup ; exit 1; }
|
||||||
|
|
||||||
|
strip_colors() {
|
||||||
|
command sed $'s/\x1b\\[[0-9;]*m//g'
|
||||||
|
}
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
unset -f nvm_download nvm_ls_remote nvm_ls_remote_iojs
|
unset -f nvm_download nvm_ls_remote nvm_ls_remote_iojs
|
||||||
if [ -n "${TEMP_NVM_COLORS-}" ]; then
|
if [ -n "${TEMP_NVM_COLORS-}" ]; then
|
||||||
@@ -45,22 +49,22 @@ nvm_download() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EXPECTED_OUTPUT_PATH="${MOCKS_DIR}/nvm ls-remote lts.txt"
|
EXPECTED_OUTPUT_PATH="${MOCKS_DIR}/nvm ls-remote lts.txt"
|
||||||
OUTPUT="$(nvm ls-remote --lts | sed 's/[ \t]*$//')"
|
OUTPUT="$(nvm ls-remote --lts | strip_colors | sed 's/[ \t]*$//')"
|
||||||
EXPECTED_OUTPUT="$(cat "${EXPECTED_OUTPUT_PATH}" | sed 's/[ \t]*$//' )"
|
EXPECTED_OUTPUT="$(cat "${EXPECTED_OUTPUT_PATH}" | strip_colors | sed 's/[ \t]*$//' )"
|
||||||
[ "_${OUTPUT}" = "_${EXPECTED_OUTPUT}" ] || die "nvm ls-remote --lts did not output expected sorted versions; got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<"
|
[ "_${OUTPUT}" = "_${EXPECTED_OUTPUT}" ] || die "nvm ls-remote --lts did not output expected sorted versions; got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<"
|
||||||
|
|
||||||
EXPECTED_OUTPUT_PATH="${MOCKS_DIR}/nvm ls-remote lts.txt"
|
EXPECTED_OUTPUT_PATH="${MOCKS_DIR}/nvm ls-remote lts.txt"
|
||||||
OUTPUT="$(nvm ls-remote "lts/*" | sed 's/[ \t]*$//')"
|
OUTPUT="$(nvm ls-remote "lts/*" | strip_colors | sed 's/[ \t]*$//')"
|
||||||
EXPECTED_OUTPUT="$(cat "${EXPECTED_OUTPUT_PATH}" | sed 's/[ \t]*$//' )"
|
EXPECTED_OUTPUT="$(cat "${EXPECTED_OUTPUT_PATH}" | strip_colors | sed 's/[ \t]*$//' )"
|
||||||
[ "_${OUTPUT}" = "_${EXPECTED_OUTPUT}" ] || die "nvm ls-remote lts/* did not output expected sorted versions; got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<"
|
[ "_${OUTPUT}" = "_${EXPECTED_OUTPUT}" ] || die "nvm ls-remote lts/* did not output expected sorted versions; got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<"
|
||||||
|
|
||||||
LTS_LIST="$(cat "${LTS_NAMES_PATH}" | tail -n +2)"
|
LTS_LIST="$(cat "${LTS_NAMES_PATH}" | tail -n +2)"
|
||||||
|
|
||||||
INDEX=1
|
INDEX=1
|
||||||
printf '%s\n' "${LTS_LIST}" | while IFS= read -r LTS; do
|
printf '%s\n' "${LTS_LIST}" | while IFS= read -r LTS; do
|
||||||
ACTUAL="$(nvm ls-remote "lts/-${INDEX}" | sed 's/[ \t]*$//')"
|
ACTUAL="$(nvm ls-remote "lts/-${INDEX}" | strip_colors | sed 's/[ \t]*$//')"
|
||||||
MESSAGE="for lts/-${INDEX} (${LTS})"
|
MESSAGE="for lts/-${INDEX} (${LTS})"
|
||||||
EXPECTED="$(nvm ls-remote "lts/${LTS}" | sed 's/[ \t]*$//')"
|
EXPECTED="$(nvm ls-remote "lts/${LTS}" | strip_colors | sed 's/[ \t]*$//')"
|
||||||
[ "${ACTUAL}" = "${EXPECTED}" ] || die "${MESSAGE}: expected >${EXPECTED}<, got >${ACTUAL}<"
|
[ "${ACTUAL}" = "${EXPECTED}" ] || die "${MESSAGE}: expected >${EXPECTED}<, got >${ACTUAL}<"
|
||||||
|
|
||||||
INDEX=$(($INDEX + 1))
|
INDEX=$(($INDEX + 1))
|
||||||
@@ -69,6 +73,7 @@ done
|
|||||||
OUTPUT="$(nvm ls-remote lts/ARGON 2>&1)"
|
OUTPUT="$(nvm ls-remote lts/ARGON 2>&1)"
|
||||||
EXIT_CODE=$?
|
EXIT_CODE=$?
|
||||||
[ $EXIT_CODE -eq 3 ] || die "nvm ls-remote lts/ARGON did not exit 3, got '${EXIT_CODE}'"
|
[ $EXIT_CODE -eq 3 ] || die "nvm ls-remote lts/ARGON did not exit 3, got '${EXIT_CODE}'"
|
||||||
|
OUTPUT="$(echo "${OUTPUT}" | strip_colors)"
|
||||||
|
|
||||||
EXPECTED_OUTPUT="LTS names must be lowercase
|
EXPECTED_OUTPUT="LTS names must be lowercase
|
||||||
N/A"
|
N/A"
|
||||||
@@ -84,8 +89,8 @@ nvm_ls_remote_iojs() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EXPECTED_OUTPUT_PATH="${MOCKS_DIR}/nvm ls-remote.txt"
|
EXPECTED_OUTPUT_PATH="${MOCKS_DIR}/nvm ls-remote.txt"
|
||||||
OUTPUT="$(nvm ls-remote | sed 's/[ \t]*$//')"
|
OUTPUT="$(nvm ls-remote | strip_colors | sed 's/[ \t]*$//')"
|
||||||
EXPECTED_OUTPUT="$(cat "${EXPECTED_OUTPUT_PATH}" | sed 's/[ \t]*$//' )"
|
EXPECTED_OUTPUT="$(cat "${EXPECTED_OUTPUT_PATH}" | strip_colors | sed 's/[ \t]*$//' )"
|
||||||
[ "_${OUTPUT}" = "_${EXPECTED_OUTPUT}" ] || die "bare nvm ls-remote did not output expected sorted versions; got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<"
|
[ "_${OUTPUT}" = "_${EXPECTED_OUTPUT}" ] || die "bare nvm ls-remote did not output expected sorted versions; got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<"
|
||||||
|
|
||||||
cleanup
|
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
|
||||||
Reference in New Issue
Block a user