[New] aliases: skip leading blank lines in alias file

Jordan Harband 2023-10-23 14:06:19 -07:00
parent 6aeab3349c
commit 8241287349
No known key found for this signature in database
GPG Key ID: 9F6A681E35EF8B56
3 changed files with 22 additions and 1 deletions

2
nvm.sh
View File

@ -1141,7 +1141,7 @@ nvm_alias() {
return 2
fi
command cat "${NVM_ALIAS_PATH}"
command awk 'NF' "${NVM_ALIAS_PATH}"
}
nvm_ls_current() {

View File

@ -0,0 +1,20 @@
#!/bin/sh
die() { echo "$@" ; exit 1; }
export NVM_DIR="$(cd ../../.. && pwd)"
\. "${NVM_DIR}/nvm.sh"
\. ../../common.sh
echo "
v0.0.1
" > ../../../alias/test-blank-lines
EXPECTED='v0.0.1'
ACTUAL="$(nvm_alias test-blank-lines)"
EXIT_CODE="$(nvm_alias test-blank-lines 2>&1 >/dev/null; echo $?)"
[ "${ACTUAL}" = "${EXPECTED}" ] || die "expected >${EXPECTED}<, got >${ACTUAL}<"
[ "${EXIT_CODE}" = '0' ] || die "expected exit code 0, got ${EXIT_CODE}"

View File

@ -15,3 +15,4 @@ rm -f "../../../alias/unstable"
rm -f "../../../alias/node"
rm -f "../../../alias/iojs"
rm -f "../../../alias/default"
rm -f "../../../alias/test-blank-lines"