Skip to content

Commit

Permalink
lib/nvm: Update autoloader to keep up with the upstream
Browse files Browse the repository at this point in the history
Fixes #504
  • Loading branch information
akinomyoga committed Dec 12, 2023
1 parent 00f28e4 commit 3303cd6
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions plugins/nvm/nvm.plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,17 @@ if _omb_util_command_exists nvm && [[ ${OMB_PLUGIN_NVM_AUTO_USE-} == true ]]; th
local nvm_version
nvm_version=$(< "$nvm_path"/.nvmrc)

# Add the `v` suffix if it does not exists in the .nvmrc file
if [[ $nvm_version != v* ]]; then
nvm_version=v$nvm_version
fi
local locally_resolved_nvm_version
# `nvm ls` will check all locally-available versions. If there are
# multiple matching versions, take the latest one. Remove the `->` and
# `*` characters and spaces. `locally_resolved_nvm_version` will be
# `N/A` if no local versions are found.
locally_resolved_nvm_version=$(nvm ls --no-colors $(<"./.nvmrc") | sed -n '${s/->//g;s/[*[:space:]]//g;p;}')

# If it is not already installed, install it
if nvm ls "$nvm_version" | grep -qx '[[:space:]]*N/A[[:space:]]*'; then
if [[ $locally_resolved_nvm_version == N/A ]]; then
nvm install "$nvm_version"
fi

if [[ $(nvm current) != "$nvm_version" ]]; then
elif [[ $(nvm current) != "$locally_resolved_nvm_version" ]]; then
nvm use "$nvm_version"
fi
fi
Expand Down

0 comments on commit 3303cd6

Please sign in to comment.