Skip to content

Commit

Permalink
[New] aliases: skip leading blank lines in alias file
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Oct 23, 2023
1 parent a747bca commit 79169a8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@ nvm_alias() {
return 2
fi

command cat "${NVM_ALIAS_PATH}"
command awk 'NF' "${NVM_ALIAS_PATH}"
}

nvm_ls_current() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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}"
1 change: 1 addition & 0 deletions test/fast/Aliases/teardown
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 79169a8

Please sign in to comment.