yw

Published See discussion on Twitter

Almost a year or more ago I stumbled across this super useful bash function that makes it incredibly easy to run scripts across a Yarn-based monorepo. Since then I haven't looked back, and have been slowly converting the rest of my team to adopt the same function in their local workflows as well!

Script:

yw() {
yarn workspace $(yarn --json workspaces info | jq '.data' -r | jq "[keys][0] []" -r | fzf) $@
}

Requirements:

  • jq
  • fzf

Both should be installable via homebrew: brew install fzf jq

Installation:

Copy the above script and dump it into your .bashrc or .zshrc, or whatever other config script your shell uses!

Note: This script is only compatible with yarn v1.22 or later, I haven't tested it on yarn v2 yet


Tags:

Snippets,
Yarn,
Monorepos,
Development Tips