mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-03-20 03:13:33 +01:00
Renamed node_modules-bin module to npm-path
Now uses npm-path instead of very slow `npm bin`
This commit is contained in:
parent
8f4c80385d
commit
9157b7c7de
2 changed files with 15 additions and 33 deletions
|
|
@ -1,33 +0,0 @@
|
|||
zsh-node_modules-bin-update-path() {
|
||||
if [[ ! -x $(which npm) ]]; then
|
||||
# there is no npm
|
||||
return
|
||||
fi
|
||||
|
||||
# figure out the path
|
||||
NPM_BIN_PATH=$(npm bin)
|
||||
|
||||
if [[ ! -d $NPM_BIN_PATH ]]; then
|
||||
# there is no dir at bin path
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ -n $OLD_NPM_BIN_PATH && $NPM_BIN_PATH == $OLD_NPM_BIN_PATH ]]; then
|
||||
# bin path did not change
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ -n $OLD_NPM_BIN_PATH ]]; then
|
||||
# remove old bin path from $path
|
||||
path[$path[(i)$OLD_NPM_BIN_PATH]]=()
|
||||
fi
|
||||
|
||||
# add new bin path to $path
|
||||
path=($NPM_BIN_PATH $path)
|
||||
export PATH
|
||||
|
||||
# for next run
|
||||
OLD_NPM_BIN_PATH=$NPM_BIN_PATH
|
||||
}
|
||||
|
||||
precmd_functions+="zsh-node_modules-bin-update-path"
|
||||
15
plugins/npm-path/npm-path.plugin.zsh
Normal file
15
plugins/npm-path/npm-path.plugin.zsh
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
zsh-node_modules-bin-update-path() {
|
||||
if [[ ! -x $(which npm) ]]; then
|
||||
# there is no npm
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ ! -r $(which npm-path) ]]; then
|
||||
echo "npm-path must be available for the oh-my-zshell npm-path module to update your PATH"
|
||||
return
|
||||
fi
|
||||
|
||||
export PATH=$(npm-path)
|
||||
}
|
||||
|
||||
precmd_functions+="zsh-node_modules-bin-update-path"
|
||||
Loading…
Add table
Add a link
Reference in a new issue