diff --git a/test/install_script/nvm_check_global_modules b/test/install_script/nvm_check_global_modules index 01d6b01..e19ed6d 100755 --- a/test/install_script/nvm_check_global_modules +++ b/test/install_script/nvm_check_global_modules @@ -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}" -# 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" +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; 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