mirror of
https://github.com/lukechilds/zsh-nvm.git
synced 2025-06-05 11:56:28 +08:00
Merge 364258fef4
into 745291dcf2
This commit is contained in:
commit
a5a56e0b2e
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user