Skip to content
Myr

[Fix] `nvm_die_on_prefix`: only grep lines starting with env var name

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

authored by Matteo De Wint · committed by Matteo De Wint · parent 00af634 · Browse files · 2 files+4 added−1 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+4 added−1 removed

  • tests:+3 added−0 removed
  • other:+1 added−1 removed

2 files+4 added−1 removed

modified:test/fast/Unit tests/nvm_die_on_prefix+3 added
82 unmodified lines
83EXIT_CODE="$(export npm_CONFIG_PREFIX=bar ; nvm_die_on_prefix 0 foo "$(nvm_version_dir new)" >/dev/null 2>&1; echo $?)"84[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'npm_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo' did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'"85[ "_$EXIT_CODE" = "_4" ] || die "'npm_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo' did not exit with 4; got '$EXIT_CODE'"8687OUTPUT="$(export FOO='NPM_CONFIG_PREFIX' ; nvm_die_on_prefix 0 foo "$(nvm_version_dir new)" 2>&1)"88[ -z "$OUTPUT" ] || die "'nvm_die_on_prefix' was not a noop; got '$OUTPUT'"8990# npmrc tests91(92 cd "${TEST_DIR}"93 touch package.json
99 unmodified lines
modified:nvm.sh+1 added-1 removed
2222 unmodified lines
2223 #2224 # here, we avoid trying to replicate "which one wins" or testing the value; if any are defined, it errors2225 # until none are left.2226 local NVM_NPM_CONFIG_PREFIX_ENV2227 NVM_NPM_CONFIG_PREFIX_ENV="$(command env | nvm_grep -i NPM_CONFIG_PREFIX | command tail -1 | command awk -F '=' '{print $1}')"2227 NVM_NPM_CONFIG_PREFIX_ENV="$(command env | nvm_grep -i ^NPM_CONFIG_PREFIX | command tail -1 | command awk -F '=' '{print $1}')"2228 if [ -n "${NVM_NPM_CONFIG_PREFIX_ENV-}" ]; then2229 local NVM_CONFIG_VALUE2230 eval "NVM_CONFIG_VALUE=\"\$${NVM_NPM_CONFIG_PREFIX_ENV}\""2231 if [ -n "${NVM_CONFIG_VALUE-}" ] && ! nvm_tree_contains_path "${NVM_DIR}" "${NVM_CONFIG_VALUE}"; then
1692 unmodified lines