[New] `nvm_resolve_alias`: only resolve one line of a multiline alias file
parent
10cdda081f
commit
6743aef70c
4
nvm.sh
4
nvm.sh
|
@ -1177,8 +1177,10 @@ nvm_resolve_alias() {
|
|||
|
||||
local SEEN_ALIASES
|
||||
SEEN_ALIASES="${ALIAS}"
|
||||
local NVM_ALIAS_INDEX
|
||||
NVM_ALIAS_INDEX=1
|
||||
while true; do
|
||||
ALIAS_TEMP="$(nvm_alias "${ALIAS}" 2>/dev/null || nvm_echo)"
|
||||
ALIAS_TEMP="$( (nvm_alias "${ALIAS}" 2>/dev/null | command head -n "${NVM_ALIAS_INDEX}" | command tail -n 1) || nvm_echo)"
|
||||
|
||||
if [ -z "${ALIAS_TEMP}" ]; then
|
||||
break
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
\. ../../../nvm.sh
|
||||
export NVM_DIR="$(cd ../../.. && pwd)"
|
||||
|
||||
\. "${NVM_DIR}/nvm.sh"
|
||||
|
||||
EXIT_CODE=$(nvm_resolve_alias ; echo $?)
|
||||
[ $EXIT_CODE = "1" ] || die "nvm_resolve_alias without an argument did not return 1; got $EXIT_CODE"
|
||||
|
@ -31,3 +33,17 @@ UNSTABLE="$(nvm_resolve_alias unstable)"
|
|||
|
||||
IOJS="$(nvm_resolve_alias iojs)"
|
||||
[ "_$IOJS" = "_iojs-v0.2" ] || die "'nvm_resolve_alias iojs' was not iojs-v0.2; got $IOJS"
|
||||
|
||||
echo "
|
||||
|
||||
v0.0.1
|
||||
v0.0.2
|
||||
v0.0.3
|
||||
" > ../../../alias/test-multi-lines
|
||||
|
||||
EXPECTED='v0.0.1'
|
||||
ACTUAL="$(nvm_resolve_alias test-multi-lines)"
|
||||
EXIT_CODE="$(nvm_resolve_alias test-multi-lines 2>&1 >/dev/null; echo $?)"
|
||||
|
||||
[ "${ACTUAL}" = "${EXPECTED}" ] || die "expected >${EXPECTED}<, got >${ACTUAL}<"
|
||||
[ "${EXIT_CODE}" = '0' ] || die "expected exit code 0, got ${EXIT_CODE}"
|
||||
|
|
|
@ -16,3 +16,4 @@ rm -f "../../../alias/node"
|
|||
rm -f "../../../alias/iojs"
|
||||
rm -f "../../../alias/default"
|
||||
rm -f "../../../alias/test-blank-lines"
|
||||
rm -f "../../../alias/test-multi-lines"
|
||||
|
|
Loading…
Reference in New Issue