-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[patch] give a more helpful message when
lts
alias is mistakenly used
- Loading branch information
Showing
2 changed files
with
25 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
test/slow/nvm use/Running 'nvm use lts' shows actionable error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |