yarn workspaces foreach
Run a command on all workspaces.
$> yarn workspaces foreach [-a,--all] [-v,--verbose] [-p,--parallel] [-i,--interlaced] [-j,--jobs #0] [-t,--topological] [--topological-dev] [--include #0] [--exclude #0] [--private] <commandName> ...
Publish all the packages in a workspace :
yarn workspaces foreach npm publish --tolerate-republish
Run build script on all the packages in a workspace :
yarn workspaces foreach run build
Run build script on all the packages in a workspace in parallel, building dependent packages first :
yarn workspaces foreach -pt run build
In order to use this command you will need to add
@yarnpkg/plugin-workspace-toolsto your plugins. Check the documentation for
yarn plugin importfor more details.
This command will run a given sub-command on all child workspaces that define it (any workspace that doesn't define it will be just skiped). Various flags can alter the exact behavior of the command:
-p,--parallelis set, the commands will run 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 overriden 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 a command after all workspaces that depend on it through the
dependenciesfield have successfully finished executing. If
--tological-devis set, both the
devDependenciesfields will be considered when figuring out the wait points.
--allis set, Yarn will run it on all the workspaces of a project. By default it runs the command only on child workspaces.
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 musn't execute the script.
-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.