Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c08b38a2a4 | ||
|
|
a07cd41af1 | ||
|
|
d1a22a63bd | ||
|
|
0d9b5c2a00 | ||
|
|
44e1d9c911 | ||
|
|
b1331c20b0 | ||
|
|
766341fca1 | ||
|
|
946da2e743 | ||
|
|
dde04f9392 | ||
|
|
ffcb5213e2 | ||
|
|
ea3b65f02e | ||
|
|
ee6f766712 | ||
|
|
edacf8275e | ||
|
|
f36516b472 | ||
|
|
dc691121b8 | ||
|
|
ce35311657 | ||
|
|
fe06825a96 | ||
|
|
a60ac08a80 |
1
.github/workflows/latest-npm.yml
vendored
1
.github/workflows/latest-npm.yml
vendored
@@ -50,6 +50,7 @@ jobs:
|
||||
with:
|
||||
allowed-endpoints:
|
||||
github.com:443
|
||||
raw.githubusercontent.com:443
|
||||
iojs.org:443
|
||||
nodejs.org:443
|
||||
registry.npmjs.org:443
|
||||
|
||||
4
.github/workflows/lint.yml
vendored
4
.github/workflows/lint.yml
vendored
@@ -12,6 +12,7 @@ jobs:
|
||||
with:
|
||||
allowed-endpoints:
|
||||
github.com:443
|
||||
raw.githubusercontent.com:443
|
||||
nodejs.org:443
|
||||
registry.npmjs.org:443
|
||||
- uses: actions/checkout@v3
|
||||
@@ -31,6 +32,7 @@ jobs:
|
||||
allowed-endpoints:
|
||||
ghcr.io:443
|
||||
github.com:443
|
||||
raw.githubusercontent.com:443
|
||||
pkg-containers.githubusercontent.com:443
|
||||
nodejs.org:443
|
||||
registry.npmjs.org:443
|
||||
@@ -50,6 +52,7 @@ jobs:
|
||||
with:
|
||||
allowed-endpoints:
|
||||
github.com:443
|
||||
raw.githubusercontent.com:443
|
||||
nodejs.org:443
|
||||
registry.npmjs.org:443
|
||||
- uses: actions/checkout@v3
|
||||
@@ -68,6 +71,7 @@ jobs:
|
||||
with:
|
||||
allowed-endpoints:
|
||||
github.com:443
|
||||
raw.githubusercontent.com:443
|
||||
- uses: actions/checkout@v3
|
||||
- name: check tests filenames
|
||||
run: ./rename_test.sh --check
|
||||
|
||||
56
.github/workflows/tests.yml
vendored
Normal file
56
.github/workflows/tests.yml
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
name: urchin tests
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
name: "tests"
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: 'script -q -e -c "${{ matrix.shell }} {0}"'
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- shell: bash
|
||||
suite: install_script
|
||||
# shell:
|
||||
# - bash
|
||||
# suite:
|
||||
# - install_script
|
||||
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@v1
|
||||
with:
|
||||
allowed-endpoints:
|
||||
github.com:443
|
||||
registry.npmjs.org:443
|
||||
raw.githubusercontent.com:443
|
||||
nodejs.org:443
|
||||
iojs.org:443
|
||||
- uses: actions/checkout@v3
|
||||
- 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/run@main
|
||||
name: 'npm install && version checks'
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
skip-ls-check: true
|
||||
shell-command: echo installed
|
||||
- run: npm ls urchin
|
||||
- run: env
|
||||
- run: make TERM=xterm-256color TEST_SUITE="${{ matrix.suite }}" SHELL="${{ matrix.shell }}" URCHIN="$(npx which urchin)" test-${{ matrix.shell }}
|
||||
|
||||
nvm:
|
||||
name: 'all test suites, all shells'
|
||||
needs: [tests]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: 'echo tests completed'
|
||||
@@ -22,7 +22,10 @@ before_install:
|
||||
- bash --version | head
|
||||
- zsh --version
|
||||
- dpkg -s dash | grep ^Version | awk '{print $2}'
|
||||
- pyenv local 3.9 || echo 'pyenv failed'
|
||||
# install python
|
||||
- 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'
|
||||
@@ -70,7 +73,6 @@ env:
|
||||
- PATH="/usr/lib/ccache/:$PATH"
|
||||
- NVM_DIR="${TRAVIS_BUILD_DIR}"
|
||||
matrix:
|
||||
- SHELL=bash TEST_SUITE=install_script
|
||||
- SHELL=sh TEST_SUITE=fast
|
||||
- SHELL=dash TEST_SUITE=fast
|
||||
- SHELL=bash TEST_SUITE=fast
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
# Please note that it'll use about 1.2 GB disk space and about 15 minutes to
|
||||
# build this image, it depends on your hardware.
|
||||
|
||||
FROM ubuntu:20.04
|
||||
FROM ubuntu:22.04
|
||||
LABEL maintainer="Peter Dave Hello <hsu@peterdavehello.org>"
|
||||
LABEL name="nvm-dev-env"
|
||||
LABEL version="latest"
|
||||
|
||||
17
README.md
17
README.md
@@ -1,6 +1,6 @@
|
||||
<a href="https://github.com/nvm-sh/logos"><img alt="nvm project logo" src="https://raw.githubusercontent.com/nvm-sh/logos/HEAD/nvm-logo-color.svg" height="50" /></a>
|
||||
|
||||
# Node Version Manager [][3] [][4] [](https://bestpractices.coreinfrastructure.org/projects/684)
|
||||
# Node Version Manager [][3] [][4] [](https://bestpractices.coreinfrastructure.org/projects/684)
|
||||
|
||||
<!-- To update this table of contents, ensure you have run `npm install` then `npm run doctoc` -->
|
||||
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
||||
@@ -599,8 +599,9 @@ cdnvm() {
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
alias cd='cdnvm'
|
||||
cd "$PWD"
|
||||
cdnvm "$PWD" || exit
|
||||
```
|
||||
|
||||
This alias would search 'up' from your current directory in order to detect a `.nvmrc` file. If it finds it, it will switch to that version; if not, it will use the default version.
|
||||
@@ -615,11 +616,14 @@ Put this into your `$HOME/.zshrc` to call `nvm use` automatically whenever you e
|
||||
```zsh
|
||||
# place this after nvm initialization!
|
||||
autoload -U add-zsh-hook
|
||||
|
||||
load-nvmrc() {
|
||||
local nvmrc_path="$(nvm_find_nvmrc)"
|
||||
local nvmrc_path
|
||||
nvmrc_path="$(nvm_find_nvmrc)"
|
||||
|
||||
if [ -n "$nvmrc_path" ]; then
|
||||
local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
|
||||
local nvmrc_node_version
|
||||
nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
|
||||
|
||||
if [ "$nvmrc_node_version" = "N/A" ]; then
|
||||
nvm install
|
||||
@@ -631,6 +635,7 @@ load-nvmrc() {
|
||||
nvm use default
|
||||
fi
|
||||
}
|
||||
|
||||
add-zsh-hook chpwd load-nvmrc
|
||||
load-nvmrc
|
||||
```
|
||||
@@ -900,9 +905,9 @@ To change the user directory and/or account name follow the instructions [here](
|
||||
|
||||
[1]: https://github.com/nvm-sh/nvm.git
|
||||
[2]: https://github.com/nvm-sh/nvm/blob/v0.39.3/install.sh
|
||||
[3]: https://travis-ci.org/nvm-sh/nvm
|
||||
[3]: https://app.travis-ci.com/nvm-sh/nvm
|
||||
[4]: https://github.com/nvm-sh/nvm/releases/tag/v0.39.3
|
||||
[Urchin]: https://github.com/scraperwiki/urchin
|
||||
[Urchin]: https://git.sdf.org/tlevine/urchin
|
||||
[Fish]: https://fishshell.com
|
||||
|
||||
**Homebrew makes zsh directories unsecure**
|
||||
|
||||
40
nvm.sh
40
nvm.sh
@@ -163,7 +163,11 @@ nvm_is_version_installed() {
|
||||
|
||||
nvm_print_npm_version() {
|
||||
if nvm_has "npm"; then
|
||||
command printf " (npm v$(npm --version 2>/dev/null))"
|
||||
local NPM_VERSION
|
||||
NPM_VERSION="$(npm --version 2>/dev/null)"
|
||||
if [ -n "${NPM_VERSION}" ]; then
|
||||
command printf " (npm v${NPM_VERSION})"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -418,7 +422,7 @@ nvm_tree_contains_path() {
|
||||
nvm_find_project_dir() {
|
||||
local path_
|
||||
path_="${PWD}"
|
||||
while [ "${path_}" != "" ] && [ ! -f "${path_}/package.json" ] && [ ! -d "${path_}/node_modules" ]; do
|
||||
while [ "${path_}" != "" ] && [ "${path_}" != '.' ] && [ ! -f "${path_}/package.json" ] && [ ! -d "${path_}/node_modules" ]; do
|
||||
path_=${path_%/*}
|
||||
done
|
||||
nvm_echo "${path_}"
|
||||
@@ -428,7 +432,7 @@ nvm_find_project_dir() {
|
||||
nvm_find_up() {
|
||||
local path_
|
||||
path_="${PWD}"
|
||||
while [ "${path_}" != "" ] && [ ! -f "${path_}/${1-}" ]; do
|
||||
while [ "${path_}" != "" ] && [ "${path_}" != '.' ] && [ ! -f "${path_}/${1-}" ]; do
|
||||
path_=${path_%/*}
|
||||
done
|
||||
nvm_echo "${path_}"
|
||||
@@ -1068,7 +1072,7 @@ nvm_list_aliases() {
|
||||
|
||||
(
|
||||
local ALIAS_NAME
|
||||
for ALIAS_NAME in "$(nvm_node_prefix)" "stable" "unstable"; do
|
||||
for ALIAS_NAME in "$(nvm_node_prefix)" "stable" "unstable" "$(nvm_iojs_prefix)"; do
|
||||
{
|
||||
# shellcheck disable=SC2030,SC2031 # (https://github.com/koalaman/shellcheck/issues/2217)
|
||||
if [ ! -f "${NVM_ALIAS_DIR}/${ALIAS_NAME}" ] && { [ -z "${ALIAS}" ] || [ "${ALIAS_NAME}" = "${ALIAS}" ]; }; then
|
||||
@@ -1077,11 +1081,6 @@ nvm_list_aliases() {
|
||||
} &
|
||||
done
|
||||
wait
|
||||
ALIAS_NAME="$(nvm_iojs_prefix)"
|
||||
# shellcheck disable=SC2030,SC2031 # (https://github.com/koalaman/shellcheck/issues/2217)
|
||||
if [ ! -f "${NVM_ALIAS_DIR}/${ALIAS_NAME}" ] && { [ -z "${ALIAS}" ] || [ "${ALIAS_NAME}" = "${ALIAS}" ]; }; then
|
||||
NVM_NO_COLORS="${NVM_NO_COLORS-}" NVM_CURRENT="${NVM_CURRENT}" nvm_print_default_alias "${ALIAS_NAME}"
|
||||
fi
|
||||
) | sort
|
||||
|
||||
(
|
||||
@@ -1135,7 +1134,7 @@ nvm_ls_current() {
|
||||
if [ "${VERSION}" = "v0.6.21-pre" ]; then
|
||||
nvm_echo 'v0.6.21'
|
||||
else
|
||||
nvm_echo "${VERSION}"
|
||||
nvm_echo "${VERSION:-none}"
|
||||
fi
|
||||
else
|
||||
nvm_echo 'system'
|
||||
@@ -1376,9 +1375,10 @@ nvm_ls() {
|
||||
|
||||
if [ "${NVM_ADD_SYSTEM-}" = true ]; then
|
||||
if [ -z "${PATTERN}" ] || [ "${PATTERN}" = 'v' ]; then
|
||||
VERSIONS="${VERSIONS}$(command printf '\n%s' 'system')"
|
||||
VERSIONS="${VERSIONS}
|
||||
system"
|
||||
elif [ "${PATTERN}" = 'system' ]; then
|
||||
VERSIONS="$(command printf '%s' 'system')"
|
||||
VERSIONS="system"
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -1889,6 +1889,7 @@ nvm_get_arch() {
|
||||
local HOST_ARCH
|
||||
local NVM_OS
|
||||
local EXIT_CODE
|
||||
local LONG_BIT
|
||||
|
||||
NVM_OS="$(nvm_get_os)"
|
||||
# If the OS is SunOS, first try to use pkgsrc to guess
|
||||
@@ -1905,6 +1906,7 @@ nvm_get_arch() {
|
||||
HOST_ARCH=ppc64
|
||||
else
|
||||
HOST_ARCH="$(command uname -m)"
|
||||
LONG_BIT="$(getconf LONG_BIT 2>/dev/null)"
|
||||
fi
|
||||
|
||||
local NVM_ARCH
|
||||
@@ -1915,12 +1917,18 @@ nvm_get_arch() {
|
||||
*) NVM_ARCH="${HOST_ARCH}" ;;
|
||||
esac
|
||||
|
||||
# If running inside a 32Bit docker container the kernel still is 64bit
|
||||
# change ARCH to 32bit if LONG_BIT is 32
|
||||
if [ "_${LONG_BIT}" = "_32" ] && [ "${NVM_ARCH}" = "x64" ]; then
|
||||
NVM_ARCH="x86"
|
||||
fi
|
||||
|
||||
# If running a 64bit ARM kernel but a 32bit ARM userland,
|
||||
# change ARCH to 32bit ARM (armv7l) if /sbin/init is 32bit executable
|
||||
local L
|
||||
if [ "$(uname)" = "Linux" ] && [ "${NVM_ARCH}" = arm64 ] &&
|
||||
L="$(command ls -dl /sbin/init 2>/dev/null)" &&
|
||||
[ "$(od -An -t x1 -j 4 -N 1 "${L#*-> }")" = ' 01' ]; then
|
||||
if [ "$(uname)" = "Linux" ] \
|
||||
&& [ "${NVM_ARCH}" = arm64 ] \
|
||||
&& [ "$(command od -An -t x1 -j 4 -N 1 "/sbin/init" 2>/dev/null)" = ' 01' ]\
|
||||
; then
|
||||
NVM_ARCH=armv7l
|
||||
HOST_ARCH=armv7l
|
||||
fi
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
"dockerfile_lint": "^0.3.4",
|
||||
"doctoc": "^2.2.1",
|
||||
"eclint": "^2.8.1",
|
||||
"markdown-link-check": "^3.10.3",
|
||||
"markdown-link-check": "^3.11.0",
|
||||
"replace": "^1.2.2",
|
||||
"semver": "^7.3.8",
|
||||
"urchin": "^0.0.5"
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
export NVM_DIR="$(cd ../../.. && pwd)"
|
||||
|
||||
\. ../../../nvm.sh
|
||||
\. ../../common.sh
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#!/bin/zsh
|
||||
|
||||
export NVM_DIR="$(cd ../../.. && pwd)"
|
||||
|
||||
\. ../../../nvm.sh
|
||||
\. ../../common.sh
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
set -ex
|
||||
|
||||
export NVM_DIR="$(cd ../.. && pwd)"
|
||||
|
||||
\. ../../nvm.sh
|
||||
|
||||
nvm alias test v0.1.2
|
||||
|
||||
@@ -4,6 +4,8 @@ set -ex
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
export NVM_DIR="$(cd ../.. && pwd)"
|
||||
|
||||
\. ../../nvm.sh
|
||||
|
||||
nvm deactivate 2>&1
|
||||
|
||||
@@ -4,6 +4,8 @@ set -ex
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
export NVM_DIR="$(cd ../.. && pwd)"
|
||||
|
||||
\. ../../nvm.sh
|
||||
\. ../common.sh
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ cleanup () {
|
||||
rm -rf "${NVM_DIR}/v0.10.4"
|
||||
}
|
||||
|
||||
export NVM_DIR="$(cd ../.. && pwd)"
|
||||
|
||||
\. ../../nvm.sh
|
||||
\. ../common.sh
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ set -ex
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
export NVM_DIR="$(cd ../.. && pwd)"
|
||||
|
||||
\. ../../nvm.sh
|
||||
|
||||
set +ex # needed for stderr
|
||||
|
||||
55
test/fast/Unit tests/nvm_download_artifact
Executable file
55
test/fast/Unit tests/nvm_download_artifact
Executable file
@@ -0,0 +1,55 @@
|
||||
#!/bin/sh
|
||||
|
||||
cleanup () {
|
||||
unset -f nvm_get_mirror
|
||||
}
|
||||
die () { echo "$@" ; cleanup ; exit 1; }
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
# bad flavor
|
||||
ACTUAL="$(nvm_download_artifact 2>&1)"
|
||||
CODE="$(nvm_download_artifact >/dev/null 2>&1 ; echo $?)"
|
||||
EXPECTED='supported flavors: node, iojs'
|
||||
EXPECTED_CODE=1
|
||||
|
||||
[ "${ACTUAL}" = "${EXPECTED}" ] || die "expected >${EXPECTED}<, got >${ACTUAL}<"
|
||||
[ "${CODE}" = $EXPECTED_CODE ] || die "expected exit code ${EXPECTED_CODE}, got ${CODE}"
|
||||
|
||||
# bad kind
|
||||
ACTUAL="$(nvm_download_artifact node 2>&1)"
|
||||
CODE="$(nvm_download_artifact node >/dev/null 2>&1 ; echo $?)"
|
||||
EXPECTED='supported kinds: binary, source'
|
||||
EXPECTED_CODE=1
|
||||
|
||||
[ "${ACTUAL}" = "${EXPECTED}" ] || die "expected >${EXPECTED}<, got >${ACTUAL}<"
|
||||
[ "${CODE}" = $EXPECTED_CODE ] || die "expected exit code ${EXPECTED_CODE}, got ${CODE}"
|
||||
|
||||
# bad type
|
||||
ACTUAL="$(nvm_download_artifact node binary nonexistentType 2>&1)"
|
||||
CODE="$(nvm_download_artifact node binary nonexistentType >/dev/null 2>&1 ; echo $?)"
|
||||
EXPECTED='unknown type of node.js or io.js release'
|
||||
EXPECTED_CODE=2
|
||||
|
||||
[ "${ACTUAL}" = "${EXPECTED}" ] || die "expected >${EXPECTED}<, got >${ACTUAL}<"
|
||||
[ "${CODE}" = $EXPECTED_CODE ] || die "expected exit code ${EXPECTED_CODE}, got ${CODE}"
|
||||
|
||||
# no version
|
||||
ACTUAL="$(nvm_download_artifact node binary std 2>&1)"
|
||||
CODE="$(nvm_download_artifact node binary std >/dev/null 2>&1 ; echo $?)"
|
||||
EXPECTED='A version number is required.'
|
||||
EXPECTED_CODE=3
|
||||
|
||||
[ "${ACTUAL}" = "${EXPECTED}" ] || die "expected >${EXPECTED}<, got >${ACTUAL}<"
|
||||
[ "${CODE}" = $EXPECTED_CODE ] || die "expected exit code ${EXPECTED_CODE}, got ${CODE}"
|
||||
|
||||
# binary type, version without binary available
|
||||
VERSION=0.8.5
|
||||
ACTUAL="$(nvm_download_artifact node binary std ${VERSION} 2>&1)"
|
||||
CODE="$(nvm_download_artifact node binary std ${VERSION} >/dev/null 2>&1 ; echo $?)"
|
||||
EXPECTED="No precompiled binary available for ${VERSION}."
|
||||
EXPECTED_CODE=0
|
||||
|
||||
[ "${ACTUAL}" = "${EXPECTED}" ] || die "expected >${EXPECTED}<, got >${ACTUAL}<"
|
||||
[ "${CODE}" = $EXPECTED_CODE ] || die "expected exit code ${EXPECTED_CODE}, got ${CODE}"
|
||||
|
||||
@@ -31,3 +31,6 @@ ACTUAL="$(PWD=$TEST_DIR/no-nesting-n_m nvm_find_project_dir)"
|
||||
|
||||
ACTUAL="$(PWD=$TEST_DIR/no-nesting-pkg nvm_find_project_dir)"
|
||||
[ "${ACTUAL}" = "$TEST_DIR/no-nesting-pkg" ] || die "no-nesting-pkg: got ${ACTUAL}"
|
||||
|
||||
ACTUAL="$(PWD="." nvm_find_project_dir)"
|
||||
[ "${ACTUAL}" = "." ] || die "insufficient permissions for pwd: got ${ACTUAL}"
|
||||
|
||||
@@ -21,5 +21,6 @@ TEST_DIR="$PWD"
|
||||
[ "~$(PWD=$TEST_DIR/tmp_nvm_find_up/a/b nvm_find_up 'test')" = "~$TEST_DIR/tmp_nvm_find_up" ] || die "failed to find 2 dirs up"
|
||||
[ "~$(PWD=$TEST_DIR/tmp_nvm_find_up/a/b/c nvm_find_up 'test')" = "~$TEST_DIR/tmp_nvm_find_up/a/b/c" ] || die "failed to find in current dir"
|
||||
[ "~$(PWD=$TEST_DIR/tmp_nvm_find_up/a/b/c/d nvm_find_up 'test')" = "~$TEST_DIR/tmp_nvm_find_up/a/b/c" ] || die "failed to find 1 level up from current dir"
|
||||
[ "~$(PWD="." nvm_find_up 'test')" = "~." ] || die "failed to handle '.' output from pwd"
|
||||
|
||||
cleanup
|
||||
|
||||
@@ -32,15 +32,17 @@ setup
|
||||
|
||||
npm install -g nop >/dev/null || die 'nvm_check_global_modules cannot be tested because `npm` cannot install the `nop` package'
|
||||
message=$(nvm_check_global_modules)
|
||||
[ ! -z "$message" ] || die "nvm_check_global_modules should have printed a notice when npm had global modules installed"
|
||||
[ ! -z "$message" ] || die "nvm_check_global_modules should have printed a notice when npm had global modules installed; got:\n${message}"
|
||||
|
||||
if [ -n "${ORIGINAL_NVM_DIR}" ]; then
|
||||
# Admit we're using NVM, just for this one test
|
||||
message=$(NVM_DIR=$ORIGINAL_NVM_DIR nvm_check_global_modules)
|
||||
[ -z "$message" ] || die "nvm_check_global_modules should not have printed a notice when npm is managed by nvm"
|
||||
message=$(NVM_DIR="${ORIGINAL_NVM_DIR}" nvm_check_global_modules)
|
||||
[ -z "$message" ] || die "nvm_check_global_modules should not have printed a notice when npm is managed by nvm; got:\n${message}"
|
||||
fi
|
||||
|
||||
npm uninstall -g nop >/dev/null
|
||||
message=$(nvm_check_global_modules)
|
||||
[ -z "$message" ] || die "nvm_check_global_modules should not have printed a notice when npm had no global modules installed"
|
||||
[ -z "$message" ] || die "nvm_check_global_modules should not have printed a notice when npm had no global modules installed; got:\n${message}"
|
||||
|
||||
# Faking an installation of npm
|
||||
mkdir -p "$npm_config_prefix/lib/node_modules/npm"
|
||||
@@ -49,7 +51,7 @@ cat <<'JSON' >"$npm_config_prefix/lib/node_modules/npm/package.json"
|
||||
JSON
|
||||
|
||||
message=$(nvm_check_global_modules)
|
||||
[ -z "$message" ] || die "nvm_check_global_modules should have not printed a notice when npm had only itself installed as a global module"
|
||||
[ -z "$message" ] || die "nvm_check_global_modules should have not printed a notice when npm had only itself installed as a global module; got:\n${message}"
|
||||
|
||||
# Faking the absence of npm
|
||||
PATH=".:$PATH"
|
||||
@@ -57,7 +59,7 @@ touch npm
|
||||
chmod +x npm
|
||||
|
||||
message=$(nvm_check_global_modules)
|
||||
[ -z "$message" ] || die "nvm_check_global_modules should have not printed a notice when npm was unavailable"
|
||||
[ -z "$message" ] || die "nvm_check_global_modules should have not printed a notice when npm was unavailable; got:\n${message}"
|
||||
|
||||
|
||||
cleanup
|
||||
|
||||
Reference in New Issue
Block a user