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
1 change: 1 addition & 0 deletions nvm-exec
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ unset NVM_CD_FLAGS
# shellcheck disable=SC1090,SC1091
\. "$DIR/nvm.sh" --no-use

nvm_rc_version > /dev/null && nvm_ensure_version_installed "$NVM_RC_VERSION";
if [ -n "$NODE_VERSION" ]; then
nvm use "$NODE_VERSION" > /dev/null || exit 127
elif ! nvm use >/dev/null 2>&1; then
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")