[Refactor] nvm_alias: use [[:space:]] instead of literal tab

[Tests] `nvm_alias`: add edge-case tests for hostile file content
This commit is contained in:
Jake Lodwick
2026-02-18 14:29:52 -07:00
committed by Jordan Harband
parent d22bf7f538
commit 304a22ad59
8 changed files with 138 additions and 3 deletions
+16
View File
@@ -0,0 +1,16 @@
#!/bin/sh
die () { echo "$@" ; exit 1; }
export NVM_DIR="$(cd ../../.. && pwd)"
: nvm.sh
\. "${NVM_DIR}/nvm.sh"
# Create an alias file with no trailing newline
printf 'v22.1.0' > ../../../alias/test-edge-no-newline
ACTUAL="$(nvm_alias test-edge-no-newline)"
EXPECTED='v22.1.0'
[ "${ACTUAL}" = "${EXPECTED}" ] || die "expected >${EXPECTED}<, got >${ACTUAL}<"
rm -f ../../../alias/test-edge-no-newline