yarn workspaces foreach
Run a command on all workspaces.
Usage
$ yarn workspaces foreach <commandName> ...
Examples
Publish all packages :
Run the build script on all descendant packages :
Run the build script on current and all descendant packages in parallel, building package dependencies first :
Run the build script on several packages and all their dependencies, building dependencies first :
Details
This command will run a given sub-command on current and all its descendant workspaces. Various flags can alter the exact behavior of the command:
-
If
-p,--parallel
is set, the commands will be ran in parallel; they'll by default be limited to a number of parallel tasks roughly equal to half your core number, but that can be overridden via-j,--jobs
, or disabled by setting-j unlimited
. -
If
-p,--parallel
and-i,--interlaced
are both set, Yarn will print the lines from the output as it receives them. If-i,--interlaced
wasn't set, it would instead buffer the output from each process and print the resulting buffers only after their source processes have exited. -
If
-t,--topological
is set, Yarn will only run the command after all workspaces that it depends on through thedependencies
field have successfully finished executing. If--topological-dev
is set, both thedependencies
anddevDependencies
fields will be considered when figuring out the wait points. -
If
-A,--all
is set, Yarn will run the command on all the workspaces of a project. -
If
-R,--recursive
is set, Yarn will find workspaces to run the command on by recursively evaluatingdependencies
anddevDependencies
fields, instead of looking at theworkspaces
fields. -
If
-W,--worktree
is set, Yarn will find workspaces to run the command on by looking at the current worktree. -
If
--from
is set, Yarn will use the packages matching the 'from' glob as the starting point for any recursive search. -
If
--since
is set, Yarn will only run the command on workspaces that have been modified since the specified ref. By default Yarn will use the refs specified by thechangesetBaseRefs
configuration option. -
If
--dry-run
is set, Yarn will explain what it would do without actually doing anything. -
The command may apply to only some workspaces through the use of
--include
which acts as a whitelist. The--exclude
flag will do the opposite and will be a list of packages that mustn't execute the script. Both flags accept glob patterns (if valid Idents and supported by micromatch). Make sure to escape the patterns, to prevent your own shell from trying to expand them.
The -v,--verbose
flag can be passed up to twice: once to prefix output lines
with the originating workspace's name, and again to include start/finish/timing
log lines. Maximum verbosity is enabled by default in terminal environments.
If the command is run
and the script being run does not exist the child
workspace will be skipped without error.
Options
Definition | Description |
---|---|
| An array of glob pattern idents or paths from which to base any recursion |
| Run the command on all workspaces of a project |
| Run the command on the current workspace and all of its recursive dependencies |
| Run the command on all workspaces of the current worktree |
| Increase level of logging verbosity up to 2 times |
| Run the commands in parallel |
| Print the output of commands in real-time instead of buffering it |
| The maximum number of parallel tasks that the execution will be limited to; or unlimited |
| Run the command after all workspaces it depends on (regular) have finished |
| Run the command after all workspaces it depends on (regular + dev) have finished |
| An array of glob pattern idents or paths; only matching workspaces will be traversed |
| An array of glob pattern idents or paths; matching workspaces won't be traversed |
| Avoid running the command on private workspaces |
| Only include workspaces that have been changed since the specified ref. |
| Print the commands that would be run, without actually running them |