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

Add Yarn directories to PATH (Fixes #9177) #9410

Closed
wants to merge 3 commits into from
Closed
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
15 changes: 15 additions & 0 deletions plugins/yarn/yarn.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,18 @@ alias yup="yarn upgrade"
alias yv="yarn version"
alias yw="yarn workspace"
alias yws="yarn workspaces"


_prepend_to_path() {
# Prepend a new directory to the path if it's not already in there
local newpath="${1:?Need path to prepend}"

# Prepend path if not already found in PATH
if ! printf "%s" "$PATH" | grep -qE "(^|:)$newpath(:|$)"; then
export PATH="$newpath:$PATH"
fi
}

# Add Yarn to path
_prepend_to_path "$HOME/.config/yarn/global/node_modules/.bin"
_prepend_to_path "$HOME/.yarn/bin"