MCPcopy
hub / github.com/adobe/react-spectrum / addDep

Function addDep

yarn.config.cjs:94–119  ·  view source on GitHub ↗
(workspace, seen = new Set())

Source from the content-addressed store, hash-verified

92function enforceNoCircularDependencies({Yarn}) {
93 // enforce that there are no circular dependencies between our packages
94 function addDep(workspace, seen = new Set()) {
95 if (seen.has(workspace.ident)) {
96 let arr = [...seen];
97 let index = arr.indexOf(workspace.ident);
98 // ok for pkg to depend on itself
99 if (arr.slice(index).length > 1) {
100 // better to error the constraints early for this for a more meaningful error message
101 throw new Error(
102 `Circular dependency detected: ${arr.slice(index).join(' -> ')} -> ${workspace.ident}`
103 );
104 } else {
105 return;
106 }
107 }
108
109 seen.add(workspace.ident);
110
111 for (let d of Yarn.dependencies({ident: workspace.ident})) {
112 if (d.type === 'peerDependencies') {
113 continue;
114 }
115 addDep(d.workspace, seen);
116 }
117
118 seen.delete(workspace.ident);
119 }
120
121 for (const workspace of Yarn.workspaces()) {
122 addDep(workspace);

Callers 1

Calls 4

sliceMethod · 0.80
deleteMethod · 0.80
hasMethod · 0.65
addMethod · 0.65

Tested by

no test coverage detected