Skip to content

Commit 8241287

Browse files
committed
[New] aliases: skip leading blank lines in alias file
1 parent 6aeab33 commit 8241287

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

nvm.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@ nvm_alias() {
11411141
return 2
11421142
fi
11431143

1144-
command cat "${NVM_ALIAS_PATH}"
1144+
command awk 'NF' "${NVM_ALIAS_PATH}"
11451145
}
11461146

11471147
nvm_ls_current() {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
3+
die() { echo "$@" ; exit 1; }
4+
5+
export NVM_DIR="$(cd ../../.. && pwd)"
6+
7+
\. "${NVM_DIR}/nvm.sh"
8+
\. ../../common.sh
9+
10+
echo "
11+
12+
v0.0.1
13+
" > ../../../alias/test-blank-lines
14+
15+
EXPECTED='v0.0.1'
16+
ACTUAL="$(nvm_alias test-blank-lines)"
17+
EXIT_CODE="$(nvm_alias test-blank-lines 2>&1 >/dev/null; echo $?)"
18+
19+
[ "${ACTUAL}" = "${EXPECTED}" ] || die "expected >${EXPECTED}<, got >${ACTUAL}<"
20+
[ "${EXIT_CODE}" = '0' ] || die "expected exit code 0, got ${EXIT_CODE}"

test/fast/Aliases/teardown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ rm -f "../../../alias/unstable"
1515
rm -f "../../../alias/node"
1616
rm -f "../../../alias/iojs"
1717
rm -f "../../../alias/default"
18+
rm -f "../../../alias/test-blank-lines"

0 commit comments

Comments
 (0)