Compare commits

...

3 Commits

Author SHA1 Message Date
Atsushi Yamamoto
ff3a10f1a5
Merge 639aaf9cd5612045b689ddb9fa6172d61509b3f8 into 4beab63631764fc381a0e56273faf8d43b8f9509 2024-08-07 09:40:04 +00:00
Jordan Harband
4beab63631
[Fix] declare an unbound variable
Fixes #3402
2024-08-07 17:38:37 +12:00
Atsushi Yamamoto
639aaf9cd5
[Tests] nvm exec/nvm run: add --silent tests 2016-10-11 23:43:10 -07:00
3 changed files with 34 additions and 4 deletions

12
nvm.sh
View File

@ -503,9 +503,9 @@ $(nvm_wrap_with_color_code 'y' "${warn_text}")"
}
nvm_process_nvmrc() {
local NVMRC_PATH="$1"
local NVMRC_PATH
NVMRC_PATH="$1"
local lines
local unpaired_line
lines=$(command sed 's/#.*//' "$NVMRC_PATH" | command sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | nvm_grep -v '^$')
@ -515,8 +515,12 @@ nvm_process_nvmrc() {
fi
# Initialize key-value storage
local keys=''
local values=''
local keys
keys=''
local values
values=''
local unpaired_line
unpaired_line=''
while IFS= read -r line; do
if [ -z "${line}" ]; then

View File

@ -0,0 +1,26 @@
#!/bin/sh
set -ex
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
echo "0.10.7" > .nvmrc
# Check nvm run without --silent
OUTPUT="$(nvm run --version | awk '{print $6}' | head -1)"
EXPECTED_OUTPUT="<0.10.7>"
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] \
|| die "\`nvm run\` failed to run; did not match with the .nvmrc version; got >${OUTPUT}<"
OUTPUT="$(nvm run --silent --version)"
EXPECTED_OUTPUT=""
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] \
|| die "\`nvm run --silent\` failed to run silently; expected no output, got >${OUTPUT}<"
# Output shouldn't be silent if --silent flag is not at the third argument position
OUTPUT="$(nvm run --version --silent)"
EXPECTED_OUTPUT=""
[ "${OUTPUT}" != "${EXPECTED_OUTPUT}" ] \
|| die "\`nvm run --version --silent\` should not be silent; expected >${OUTPUT}<, got no output"