[Fix] nvm ls, nvm alias, nvm install: error when an LTS name is invalid

This commit is contained in:
Jordan Harband
2024-09-04 13:55:11 -07:00
parent 9fb9dec710
commit da2720a429
5 changed files with 67 additions and 17 deletions

View File

@@ -1,7 +1,5 @@
#!/bin/sh
set -e
die () { echo "$@" ; cleanup ; exit 1; }
cleanup() {
@@ -56,6 +54,14 @@ printf '%s\n' "${LTS_LIST}" | while IFS= read -r LTS; do
INDEX=$(($INDEX + 1))
done
OUTPUT="$(nvm ls-remote lts/ARGON 2>&1)"
EXIT_CODE=$?
[ $EXIT_CODE -eq 3 ] || die "nvm ls-remote lts/ARGON did not exit 3, got '${EXIT_CODE}'"
EXPECTED_OUTPUT="LTS names must be lowercase
N/A"
[ "_${OUTPUT}" = "_${EXPECTED_OUTPUT}" ] || die "nvm ls-remote lts/ARGON did not output expected error message; got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<"
REMOTE="${PWD}/mocks/nvm_ls_remote.txt"
nvm_ls_remote() {
cat "${REMOTE}"