yarn workspaces foreach
To use this command, first install the
yarn plugin import workspace-tools
Run a command on all workspaces.
$> yarn workspaces foreach <commandName> ...
Publish current and all descendant packages :
yarn workspaces foreach npm publish --tolerate-republish
Run build script on current and all descendant packages :
yarn workspaces foreach run build
Run build script on current and all descendant packages in parallel, building dependent packages first :
yarn workspaces foreach -pt run build
||Find packages via dependencies/devDependencies instead of using the workspaces field|
||Run the command on all workspaces of a project|
||Prefix each output line with the name of the originating workspace|
||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|
||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; only matching workspaces will be traversed|
||An array of glob pattern idents; matching workspaces won't be traversed|
||Avoid running the command on private workspaces|
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:
-p,--parallelis 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
-i,--interlacedare both set, Yarn will print the lines from the output as it receives them. If
-i,--interlacedwasn't set, it would instead buffer the output from each process and print the resulting buffers only after their source processes have exited.
-t,--topologicalis set, Yarn will only run the command after all workspaces that it depends on through the
dependenciesfield have successfully finished executing. If
--topological-devis set, both the
devDependenciesfields will be considered when figuring out the wait points.
-A,--allis set, Yarn will run the command on all the workspaces of a project. By default yarn runs the command only on current and all its descendant workspaces.
-R,--recursiveis set, Yarn will find workspaces to run the command on by recursively evaluating
devDependenciesfields, instead of looking at the
The command may apply to only some workspaces through the use of
--includewhich acts as a whitelist. The
--excludeflag 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.
-v,--verbose flag will cause Yarn to print more information; in
particular the name of the workspace that generated the output will be printed
at the front of each line.
If the command is
run and the script being run does not exist the child
workspace will be skipped without error.