Open chenxinyanc opened 6 months ago
The project root is indeed a workspace, so --all
will include it. yarn workspace foreach --all --exclude .
should work well enough, so probably not worth adding another flag for excluding current workspace.
The project root is indeed a workspace, so
--all
will include it.yarn workspace foreach --all --exclude .
should work well enough, so probably not worth adding another flag for excluding current workspace.
Thanks for the suggestion! I think --exclude .
looks more general than --exclude <root-package-name>
and I that should resolve my problem here.
While I may not be able to contribute for now, may I suggest adding some documentation/notice on this potential pitfall?
Self-service
Describe the bug
Suppose I'm working with a monorepo set up with yarn workspace, and there is a build script named
test
defined in the package.json of some workspace child packages.Now I want to trigger tests of every workspace child packages in one go from the workspace root, so I've added the following script in the workspace root-level package.json file
If I run
yarn test:coverage
at workspace root, I'll find thetest
script from workspace root-level package is also executed (i.e., theyarn workspaces foreach --parallel --interlaced --verbose --all run test --run
, resulting thetest
scripts of each child packages being executed twice!I'm not sure whether this is a bug or by design, but could you please provide some suggestions on this?
yarn workspaces foreach
?--exclude
could be helpful, but is there any more idiomatic way to do so?To reproduce
n.b.: The link
https://yarnpkg.com/advanced/sherlock
seems to be brokenHere is the repo for reproduction: https://github.com/chenxinyanc/yarn-v4-workspace-foreach-args
Environment
Additional context
No response