From 87583c2f96f437f0de194a2c44caba8ae88efeee Mon Sep 17 00:00:00 2001 From: Filip Dimovski Date: Wed, 26 Apr 2017 12:19:20 +0000 Subject: [PATCH] Install a version before use Now 'nvm use' checks whether the version is installed before it is used. If the version is missing, it will call 'nvm install' and install it. Otherwise, if the version is present, it will use it and continue as usual. --- nvm.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nvm.sh b/nvm.sh index 82a4105..5ad022f 100644 --- a/nvm.sh +++ b/nvm.sh @@ -2682,6 +2682,12 @@ nvm() { return 127 fi + # Install version if not available + if ! nvm ls "$PROVIDED_VERSION" &>/dev/null; then + nvm install "$PROVIDED_VERSION" + return + fi + if [ "_$VERSION" = '_system' ]; then if nvm_has_system_node && nvm deactivate >/dev/null 2>&1; then if [ $NVM_USE_SILENT -ne 1 ]; then