From 4cdbdaead8bca8487b27948f248aa2b3d79878f7 Mon Sep 17 00:00:00 2001 From: Tobias Gurtzick Date: Sun, 27 Aug 2017 00:45:44 +0200 Subject: [PATCH] add descriptive error message an replace test stub --- nvm.sh | 1 + test/fast/Unit tests/nvm_die_on_prefix | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/nvm.sh b/nvm.sh index 37a5a6f..d79a795 100644 --- a/nvm.sh +++ b/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 diff --git a/test/fast/Unit tests/nvm_die_on_prefix b/test/fast/Unit tests/nvm_die_on_prefix index 3ce4a35..95a5f60 100755 --- a/test/fast/Unit tests/nvm_die_on_prefix +++ b/test/fast/Unit tests/nvm_die_on_prefix @@ -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\"