summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorMarc Cornellà <hello@mcornella.com>2021-12-29 15:19:59 +0100
committerMarc Cornellà <hello@mcornella.com>2021-12-29 15:19:59 +0100
commit4ef188cebf054896b47aa91181dacc2c674b5063 (patch)
tree8b2e566cf9b5970e36d19a01978db2036fd590ae /plugins
parentc155531402a2ca19490aa81818a0f4f58f73cabf (diff)
downloadzsh-4ef188cebf054896b47aa91181dacc2c674b5063.tar.gz
zsh-4ef188cebf054896b47aa91181dacc2c674b5063.tar.bz2
zsh-4ef188cebf054896b47aa91181dacc2c674b5063.zip
perf(yarn): skip `yarn` call if default global bin directory exists (#10290)
Fixes #10290
Diffstat (limited to 'plugins')
-rw-r--r--plugins/yarn/yarn.plugin.zsh7
1 files changed, 5 insertions, 2 deletions
diff --git a/plugins/yarn/yarn.plugin.zsh b/plugins/yarn/yarn.plugin.zsh
index a4f595c61..9ba24420a 100644
--- a/plugins/yarn/yarn.plugin.zsh
+++ b/plugins/yarn/yarn.plugin.zsh
@@ -1,5 +1,8 @@
-# Add yarn bin directory to $PATH if it exists and not in $PATH already
-bindir=$(yarn global bin 2>/dev/null) \
+# Skip yarn call if default global bin dir exists
+[[ -d "$HOME/.yarn/bin" ]] && bindir="$HOME/.yarn/bin" || bindir="$(yarn global bin 2>/dev/null)"
+
+# Add yarn bin directory to $PATH if it exists and not already in $PATH
+[[ $? -eq 0 ]] \
&& [[ -d "$bindir" ]] \
&& (( ! ${path[(Ie)$bindir]} )) \
&& path+=("$bindir")