Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] nvm exec: Do a version check on nvm-exec #3308

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ No NODE_VERSION provided; no .nvmrc file found";

# Skip install, we want to test the error message
diff <(echo "${EXPECTED}") <(echo "${OUTPUT}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line can't work tho, due to https://www.shellcheck.net/wiki/SC3001 - i'll change this to a normal = comparison unless you have a better idea

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, sound reasonable.
Was hoping that the #!/bin/bash on top would allow for that to pass, but I think = should work too.

rm .nvmrc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aha, good catch. note tho that this doesn't actually restore what might already be present - we should back up and restore the existing .nvmrc in setup/teardown files

i'll take a crack at this part tho

8 changes: 4 additions & 4 deletions test/fast/Set Colors/nvm_print_versions calls nvm_get_colors
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

\. ../../../nvm.sh

set -e
#set -e #nvm use system returns 127 and No system set message

die () {
# echo "$@" ;
Expand All @@ -24,7 +24,7 @@ fi
# default system color
nvm use system
OUTPUT=$(nvm_print_versions system)
FORMAT="\033[0;32m-> %12s\033[0m"
FORMAT="\033[0;33m%15s\033[0m"
VERSION='system'
EXPECTED_OUTPUT=$(command printf -- "${FORMAT}\\n" "${VERSION}")

Expand All @@ -34,7 +34,7 @@ nvm_ls_current() { echo "current";}

# default current color
OUTPUT=$(nvm_print_versions current)
FORMAT="\033[0;32m-> %12s\033[0m"
FORMAT="\033[0;32m->%13s\033[0m"
VERSION="current"
EXPECTED_OUTPUT=$(command printf -- "${FORMAT}\\n" "${VERSION}")

Expand All @@ -43,7 +43,7 @@ EXPECTED_OUTPUT=$(command printf -- "${FORMAT}\\n" "${VERSION}")
# custom current color
nvm set-colors YCMGR
OUTPUT=$(nvm_print_versions current)
FORMAT="\033[1;35m-> %12s\033[0m"
FORMAT="\033[1;35m->%13s\033[0m"
VERSION="current"
EXPECTED_OUTPUT=$(command printf -- "${FORMAT}\\n" "${VERSION}")

Expand Down
20 changes: 20 additions & 0 deletions test/slow/Running 'nvm-exec' should display required node version
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

set -x
\. ../../nvm.sh

NVM_TEST_VERSION=v9

# Remove the stuff we're clobbering.
[ -e ../../$NVM_TEST_VERSION ] && rm -R ../../$NVM_TEST_VERSION

# Write it to nvmrc
echo "$NVM_TEST_VERSION" > .nvmrc

output="$(../../nvm-exec 2>&1)";
expected='N/A: version "v9" is not yet installed.

You need to run `nvm install v9` to install and use it.
No NODE_VERSION provided; no .nvmrc file found';
# Skip install, we want to test the error message
diff <(echo "$expected") <(echo "$output")
Loading