Compare commits

..

5 Commits

Author SHA1 Message Date
Reetik Rajan
dcc618006b
Merge 70afc73fa5457068282529e36549b5b1895c872d into da2720a4292d02746a6b7fdc680c7e163c347355 2024-10-05 06:41:27 +00:00
Reetik Rajan
70afc73fa5 updated error message test 2024-10-05 12:11:21 +05:30
Reetik Rajan
68fe9f1b80
accepting suggestion
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2024-10-05 12:09:32 +05:30
Reetik Rajan
d8d653147c fixed lint error - final newline 2024-10-05 11:38:17 +05:30
Reetik Rajan
0ad41dd1c2 test for 'nvm use lts' to show actionable error 2024-10-05 11:32:56 +05:30
2 changed files with 20 additions and 1 deletions

2
nvm.sh
View File

@ -701,7 +701,7 @@ nvm_ensure_version_installed() {
fi
nvm_err ""
if [ "${PROVIDED_VERSION}" = 'lts' ]; then
nvm_err "You need to run \`nvm install --lts\` to install and \`nvm use --lts\` to use it."
nvm_err "`lts` is not an alias - you may need to run \`nvm install --lts\` to install and \`nvm use --lts\` to use it."
elif [ "${IS_VERSION_FROM_NVMRC}" != '1' ]; then
nvm_err "You need to run \`nvm install ${PROVIDED_VERSION}\` to install and use it."
else

View File

@ -0,0 +1,19 @@
#!/bin/sh
set -ex
die () { echo "$@" ; exit 1; }
\. ../../../nvm.sh
# Deactivate any active node version
nvm deactivate >/dev/null 2>&1 || die 'deactivate failed'
# Attempt to use 'lts' without '--' and capture the error message
ERROR_OUTPUT=$(nvm use lts 2>&1) || true
EXPECTED_ERROR="`lts` is not an alias - you may need to run \`nvm install --lts\` to install and \`nvm use --lts\` to use it."
# Check if the error message matches the expected output
echo "$ERROR_OUTPUT" | grep -q "$EXPECTED_ERROR" \
|| die "Expected error message not found. Got: $ERROR_OUTPUT"