Skip to content

Commit

Permalink
Add packages-with-prefix script
Browse files Browse the repository at this point in the history
For easily modifying groups of packages under a common path when working
with 'yarn workspaces foreach'. E.g

yarn workspaces foreach `./packages-with-prefix packages/sdk` version major
  • Loading branch information
piersy committed May 27, 2021
1 parent c7f1b52 commit cc64e67
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages-with-prefix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

# This script expects a string as its only agrument and will produce output of
# the form '--include XXX --include XXX' where XXX is the package name for all
# workspaces where the given string is a prefix of the workspace path.
#
# It is intended for use with the 'yarn workspaces foreach' command to make it
# easy to run commands for all workspaces in a given directory.

for x in $(yarn workspaces list | grep $1 | awk '{print $3}'); do (cd $x && node -p "'--include ' + require('./package').name"); done | tr '\n' ' '

0 comments on commit cc64e67

Please sign in to comment.