From 89f35361baf8a649706ac98ca262ab78f8960b12 Mon Sep 17 00:00:00 2001 From: Michael Day Date: Mon, 22 May 2023 15:46:53 -0500 Subject: [PATCH] Auto-switch the node version if found --- setup.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index 44046fc..f97f3bd 100644 --- a/setup.sh +++ b/setup.sh @@ -15,7 +15,18 @@ plugindirname=$(basename "$plugindir") nodeversion=$( node -v ); if [[ $nodeversion != v14* ]]; then echo "Your version of node needs to be v14, but it is set to be "$nodeversion; - exit 1; + echo "Checking available versions before automatically switching..."; + + source ~/.nvm/nvm.sh + availablenodeversions=$( nvm ls ); + if [[ ${availablenodeversions[*]} =~ v14* ]]; + then + echo "v14 found. Switching your current version..."; + nvm use 14; + else + echo "Please install node v14, then run this script again."; + exit 1; + fi fi # Install dependencies.