From e2ff1e7f088d260af7a810f4c522949132518d68 Mon Sep 17 00:00:00 2001 From: Bark Date: Wed, 6 Mar 2024 16:03:10 +0200 Subject: [PATCH 1/3] fix: Do a version check on `nvm-exec` This check would display a message in case the `.nvmrc` version is not installed, and would not alter the output otherwise. --- nvm-exec | 1 + 1 file changed, 1 insertion(+) diff --git a/nvm-exec b/nvm-exec index 44d5ddb..c082f8f 100755 --- a/nvm-exec +++ b/nvm-exec @@ -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 From 5a28180ed6072b892bc2dc342c5c08a33c93121f Mon Sep 17 00:00:00 2001 From: "Stiliyan Tonev (Bark)" Date: Tue, 30 Jul 2024 11:51:32 +0300 Subject: [PATCH 2/3] tests: Add test to check if the message contains the relevant information. --- ...vm-exec' should display required node version | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 test/slow/Running 'nvm-exec' should display required node version diff --git a/test/slow/Running 'nvm-exec' should display required node version b/test/slow/Running 'nvm-exec' should display required node version new file mode 100644 index 0000000..53b149b --- /dev/null +++ b/test/slow/Running 'nvm-exec' should display required node version @@ -0,0 +1,16 @@ +#!/bin/sh + +set -ex +die () { echo "$@" ; exit 1; } +\. ../../../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 + +# Skip install, we want to test the error message +nvm-exec From 650b069bb83c0d704cb48e2a59468a021d7cdcd8 Mon Sep 17 00:00:00 2001 From: "Stiliyan Tonev (Bark)" Date: Tue, 30 Jul 2024 11:56:35 +0300 Subject: [PATCH 3/3] Seems changes done in docker do not persist, had to reapply them --- ...'nvm-exec' should display required node version | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/test/slow/Running 'nvm-exec' should display required node version b/test/slow/Running 'nvm-exec' should display required node version index 53b149b..8c91cf7 100644 --- a/test/slow/Running 'nvm-exec' should display required node version +++ b/test/slow/Running 'nvm-exec' should display required node version @@ -1,8 +1,7 @@ -#!/bin/sh +#!/bin/bash -set -ex -die () { echo "$@" ; exit 1; } -\. ../../../nvm.sh +set -x +\. ../../nvm.sh NVM_TEST_VERSION=v9 @@ -12,5 +11,10 @@ NVM_TEST_VERSION=v9 # 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 -nvm-exec +diff <(echo "$expected") <(echo "$output")