This commit is contained in:
Max O'Cull 2024-07-03 00:49:40 -04:00 committed by GitHub
commit a5a56e0b2e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -38,11 +38,20 @@ _zsh_nvm_global_binaries() {
_zsh_nvm_load() {
if [[ "$NVM_CACHE_LOAD" == true ]]; then
# Strip out the old cached version of node that we were using.
export PATH="$(sed -e 's|[^:]*versions/node[^:]*[:]||g' <<< "$PATH")"
fi
# Source nvm (check if `nvm use` should be ran after load)
if [[ "$NVM_NO_USE" == true ]]; then
source "$NVM_DIR/nvm.sh" --no-use
else
source "$NVM_DIR/nvm.sh"
if [[ "$NVM_CACHE_LOAD" == true ]]; then
export NVM_CACHE_LOAD_PATH_NVM="$(awk -F ':' '{ print $1 }' <<< "$PATH")"
echo "$NVM_CACHE_LOAD_PATH_NVM" > "${HOME}/.zsh_nvm_cache"
fi
fi
# Rename main nvm function
@ -78,6 +87,14 @@ _zsh_nvm_completion() {
}
_zsh_nvm_lazy_load() {
if [[ "$NVM_CACHE_LOAD" == true ]] && [[ -s "${HOME}/.zsh_nvm_cache" ]]; then
export NVM_CACHE_LOAD_PATH_NVM="$(cat "${HOME}/.zsh_nvm_cache")"
# Add it to path if it doesn't already exist.
if [ -d "$NVM_CACHE_LOAD_PATH_NVM" ] && [[ ":$PATH:" != *":$NVM_CACHE_LOAD_PATH_NVM:"* ]]; then
export PATH="${NVM_CACHE_LOAD_PATH_NVM}${PATH:+":$PATH"}"
fi
fi
# Get all global node module binaries including node
# (only if NVM_NO_USE is off)