Skip to content

Commit

Permalink
feat(yarn): adding option to disable PATH modifying
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosala committed Feb 1, 2022
1 parent 0be7c89 commit 824bdcc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
9 changes: 9 additions & 0 deletions plugins/yarn/README.md
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
@@ -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

0 comments on commit 824bdcc

Please sign in to comment.