Skip to content
Myr

Add support for `$NPM_CONFIG_PREFIX` to `nvm_die_on_prefix`.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fixes #606.

authored by Jordan Harband · committed by Jordan Harband · parent 1458de7 · Browse files · 2 files+16 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+16 added−2 removed

  • tests:+8 added−1 removed
  • other:+8 added−1 removed

2 files+16 added−2 removed

modified:test/fast/Unit tests/nvm_die_on_prefix+8 added-1 removed
48 unmodified lines
49EXIT_CODE="$(PREFIX=bar nvm_die_on_prefix 0 foo >/dev/null 2>&1; echo $?)"50[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'PREFIX=bar nvm_die_on_prefix 0 foo' did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'"51[ "_$EXIT_CODE" = "_3" ] || die "'PREFIX=bar nvm_die_on_prefix 0 foo' did not exit with 3; got '$EXIT_CODE'"5253OUTPUT="$(NPM_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo 2>&1)"54EXPECTED_OUTPUT='nvm is not compatible with the "NPM_CONFIG_PREFIX" environment variable: currently set to "bar"55Run `unset NPM_CONFIG_PREFIX` to unset it.'56EXIT_CODE="$(NPM_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo >/dev/null 2>&1; echo $?)"57[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'NPM_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo' did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'"58[ "_$EXIT_CODE" = "_4" ] || die "'NPM_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo' did not exit with 4; got '$EXIT_CODE'"5960npm() {61 local args62 args="$@"63 if [ "_$args" = "_config get prefix" ]; then
4 unmodified lines
68EXPECTED_OUTPUT="nvm is not compatible with the npm config \"prefix\" option: currently set to \"./bad prefix\"69Run \`npm config delete prefix\` or \`foo\` to unset it."70EXIT_CODE="$(nvm_die_on_prefix 0 foo >/dev/null 2>&1; echo $?)"71[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_die_on_prefix 0 foo' did not error with '$EXPECTED_OUTPUT' with bad prefix set; got '$OUTPUT'"65[ "_$EXIT_CODE" = "_4" ] || die "'nvm_die_on_prefix 0 foo' did not exit with 4 with bad prefix set; got '$EXIT_CODE'"72[ "_$EXIT_CODE" = "_10" ] || die "'nvm_die_on_prefix 0 foo' did not exit with 10 with bad prefix set; got '$EXIT_CODE'"7374cleanup
modified:nvm.sh+8 added-1 removed
1272 unmodified lines
1273 echo >&2 "Run \`unset PREFIX\` to unset it."1274 return 31275 fi12761277 if [ -n "$NPM_CONFIG_PREFIX" ] && ! (nvm_tree_contains_path "$NVM_DIR" "$NPM_CONFIG_PREFIX" >/dev/null 2>&1); then1278 nvm deactivate >/dev/null 2>&11279 echo >&2 "nvm is not compatible with the \"NPM_CONFIG_PREFIX\" environment variable: currently set to \"$NPM_CONFIG_PREFIX\""1280 echo >&2 "Run \`unset NPM_CONFIG_PREFIX\` to unset it."1281 return 41282 fi12831284 if ! nvm_has 'npm'; then1285 return1286 fi1287
9 unmodified lines
1297 echo >&2 "Run \`npm config delete prefix\` or \`$NVM_COMMAND\` to unset it."1298 else1299 echo >&2 "Run \`$NVM_COMMAND\` to unset it."1300 fi1294 return 41301 return 101302 fi1303 fi1304}1305
822 unmodified lines