From c2a24b266d014700327925c10d2a70282fec8ba6 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 4 Sep 2024 13:54:41 -0700 Subject: [PATCH] [Fix] `nvm_normalize_lts`: error when an LTS name is not lowercase --- nvm.sh | 4 ++++ test/fast/Unit tests/nvm_normalize_lts | 3 +++ 2 files changed, 7 insertions(+) diff --git a/nvm.sh b/nvm.sh index d991ff0e13..ce8bba56a1 100755 --- a/nvm.sh +++ b/nvm.sh @@ -891,6 +891,10 @@ nvm_normalize_lts() { fi ;; *) + if [ "${LTS}" != "$(echo "${LTS}" | command tr '[:upper:]' '[:lower:]')" ]; then + nvm_err 'LTS names must be lowercase' + return 3 + fi nvm_echo "${LTS}" ;; esac diff --git a/test/fast/Unit tests/nvm_normalize_lts b/test/fast/Unit tests/nvm_normalize_lts index 0844f95cf0..8f4f20db78 100755 --- a/test/fast/Unit tests/nvm_normalize_lts +++ b/test/fast/Unit tests/nvm_normalize_lts @@ -16,6 +16,9 @@ ACTUAL="$(nvm_normalize_lts "lts/*")" EXPECTED='lts/*' [ "${ACTUAL}" = "${EXPECTED}" ] || die "expected >${EXPECTED}<, got >${ACTUAL}<" +if ACTUAL="$(nvm_normalize_lts lts/ARGON)"; then + die "expected failure, got >${ACTUAL}<" +fi MOCKS_DIR="../Unit tests/mocks" STAR="$(cat "$MOCKS_DIR/lts-star.txt")"