Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .yarn/versions/4b66efea.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
releases:
"@yarnpkg/cli": patch
"@yarnpkg/core": patch

declined:
- "@yarnpkg/plugin-compat"
- "@yarnpkg/plugin-constraints"
- "@yarnpkg/plugin-dlx"
- "@yarnpkg/plugin-essentials"
- "@yarnpkg/plugin-exec"
- "@yarnpkg/plugin-file"
- "@yarnpkg/plugin-git"
- "@yarnpkg/plugin-github"
- "@yarnpkg/plugin-http"
- "@yarnpkg/plugin-init"
- "@yarnpkg/plugin-interactive-tools"
- "@yarnpkg/plugin-link"
- "@yarnpkg/plugin-nm"
- "@yarnpkg/plugin-npm"
- "@yarnpkg/plugin-npm-cli"
- "@yarnpkg/plugin-pack"
- "@yarnpkg/plugin-patch"
- "@yarnpkg/plugin-pnp"
- "@yarnpkg/plugin-pnpm"
- "@yarnpkg/plugin-stage"
- "@yarnpkg/plugin-typescript"
- "@yarnpkg/plugin-version"
- "@yarnpkg/plugin-workspace-tools"
- "@yarnpkg/builder"
- "@yarnpkg/doctor"
- "@yarnpkg/extensions"
- "@yarnpkg/nm"
- "@yarnpkg/pnpify"
- "@yarnpkg/sdks"
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,9 @@ exports[`Commands workspace foreach should run on current and descendant workspa
"stderr": "",
"stdout": "Test Workspace C
Test Workspace D
Test Workspace E
Test Workspace F
Test Workspace G
Test Workspace E
Done
",
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,27 @@ describe(`Commands`, () => {
),
);

test(
`should support self referencing workspaces field`,
makeTemporaryEnv(
{
private: true,
workspaces: [`.`],
},
async ({path, run}) => {
await run(`install`);

await expect(run(`workspaces`, `foreach`, `--worktree`, `exec`, `echo`, `42`)).resolves.toMatchObject(
{
code: 0,
stdout: `42\nDone\n`,
stderr: ``,
},
);
},
),
);

test(
`should execute 'node' command`,
makeTemporaryEnv(
Expand Down
16 changes: 10 additions & 6 deletions packages/yarnpkg-core/sources/Workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,17 +197,21 @@ export class Workspace {
* @returns all the child workspaces
*/
getRecursiveWorkspaceChildren() {
const workspaceList: Array<Workspace> = [];
const workspaceSet = new Set<Workspace>([this]);

for (const childWorkspaceCwd of this.workspacesCwds) {
const childWorkspace = this.project.workspacesByCwd.get(childWorkspaceCwd);
for (const workspace of workspaceSet) {
for (const childWorkspaceCwd of workspace.workspacesCwds) {
const childWorkspace = this.project.workspacesByCwd.get(childWorkspaceCwd);

if (childWorkspace) {
workspaceList.push(childWorkspace, ...childWorkspace.getRecursiveWorkspaceChildren());
if (childWorkspace) {
workspaceSet.add(childWorkspace);
}
}
}

return workspaceList;
workspaceSet.delete(this);

return Array.from(workspaceSet);
}

async persistManifest() {
Expand Down