File tree 2 files changed +25
-4
lines changed
2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -700,10 +700,12 @@ nvm_ensure_version_installed() {
700
700
nvm_err " N/A: version \" ${PREFIXED_VERSION:- $PROVIDED_VERSION } \" is not yet installed."
701
701
fi
702
702
nvm_err " "
703
- if [ " ${IS_VERSION_FROM_NVMRC} " != ' 1' ]; then
704
- nvm_err " You need to run \` nvm install ${PROVIDED_VERSION} \` to install and use it."
705
- else
706
- nvm_err ' You need to run `nvm install` to install and use the node version specified in `.nvmrc`.'
703
+ if [ " ${PROVIDED_VERSION} " = ' lts' ]; then
704
+ nvm_err ' `lts` is not an alias - you may need to run `nvm install --lts` to install and `nvm use --lts` to use it.'
705
+ elif [ " ${IS_VERSION_FROM_NVMRC} " != ' 1' ]; then
706
+ nvm_err " You need to run \` nvm install ${PROVIDED_VERSION} \` to install and use it."
707
+ else
708
+ nvm_err ' You need to run `nvm install` to install and use the node version specified in `.nvmrc`.'
707
709
fi
708
710
return 1
709
711
fi
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ set -ex
4
+
5
+ die () { echo " $@ " ; exit 1; }
6
+
7
+ \. ../../../nvm.sh
8
+
9
+ # Deactivate any active node version
10
+ nvm deactivate > /dev/null 2>&1 || die ' deactivate failed'
11
+
12
+ # Attempt to use 'lts' without '--' and capture the error message
13
+ ERROR_OUTPUT=$( nvm use lts 2>&1 ) || true
14
+
15
+ EXPECTED_ERROR=' `lts` is not an alias - you may need to run `nvm install --lts` to install and `nvm use --lts` to use it.'
16
+
17
+ # Check if the error message matches the expected output
18
+ echo " $ERROR_OUTPUT " | grep -q " $EXPECTED_ERROR " \
19
+ || die " Expected error message not found. Got: $ERROR_OUTPUT "
You can’t perform that action at this time.
0 commit comments