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

feat(yarn): add setting to disable adding global dir to $PATH #10642

Merged
merged 1 commit into from
Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions plugins/yarn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ To use it, add `yarn` to the plugins array in your zshrc file:
plugins=(... yarn)
```

## Global scripts directory

It also adds `yarn` global scripts dir (commonly `~/.yarn/bin`) to the `$PATH`.
To disable this feature, set the following style in your `.zshrc`:

```zsh
zstyle ':omz:plugins:yarn' global-path false
```

## Aliases

| Alias | Command | Description |
Expand Down
18 changes: 10 additions & 8 deletions plugins/yarn/yarn.plugin.zsh
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Skip yarn call if default global bin dir exists
[[ -d "$HOME/.yarn/bin" ]] && bindir="$HOME/.yarn/bin" || bindir="$(yarn global bin 2>/dev/null)"
if zstyle -T ':omz:plugins:yarn' global-path; then
# 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")
unset bindir
# Add yarn bin directory to $PATH if it exists and not already in $PATH
[[ $? -eq 0 ]] \
&& [[ -d "$bindir" ]] \
&& (( ! ${path[(Ie)$bindir]} )) \
&& path+=("$bindir")
unset bindir
fi

alias y="yarn"
alias ya="yarn add"
Expand Down