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

lib/nvm: update autoloader to keep up with the upstream #506

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading