mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-05-10 22:31:51 +00:00
add descriptive error message an replace test stub
This commit is contained in:
parent
127eb414da
commit
4cdbdaead8
1
nvm.sh
1
nvm.sh
@ -2112,6 +2112,7 @@ nvm_die_on_prefix() {
|
||||
if [ -f "${npmrc}/.npmrc" ]; then
|
||||
NVM_NPM_PREFIX=$(grep ^prefix= "${npmrc}"/.npmrc | sed s/prefix=\\\(.*\\\)$/\\1/)
|
||||
if ! [ -z "$NVM_NPM_PREFIX" ]; then
|
||||
nvm_err "Incompatible prefix setting prefix=${npmrc} found in the config file ${npmrc}/.npmrc"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
|
@ -57,12 +57,10 @@ EXIT_CODE="$(NPM_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo >/dev/null 2>&1; echo
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'NPM_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo' did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||
[ "_$EXIT_CODE" = "_4" ] || die "'NPM_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo' did not exit with 4; got '$EXIT_CODE'"
|
||||
|
||||
npm() {
|
||||
sed() {
|
||||
local args
|
||||
args="$@"
|
||||
if [ "_$args" = "_config --loglevel=warn get prefix" ]; then
|
||||
echo "./bad prefix"
|
||||
fi
|
||||
echo "./bad prefix"
|
||||
}
|
||||
OUTPUT="$(nvm_die_on_prefix 0 foo 2>&1)"
|
||||
EXPECTED_OUTPUT="nvm is not compatible with the npm config \"prefix\" option: currently set to \"./bad prefix\"
|
||||
|
Loading…
Reference in New Issue
Block a user