(itemName: string, path: string[])
| 156 | }; |
| 157 | |
| 158 | const visit = async (itemName: string, path: string[]): Promise<void> => { |
| 159 | if (visited.has(itemName)) return; |
| 160 | if (visiting.has(itemName)) { |
| 161 | const cycleStart = path.indexOf(itemName); |
| 162 | const cyclePath = [...path.slice(cycleStart), itemName].join(" -> "); |
| 163 | throw new Error(`Circular registryDependencies detected: ${cyclePath}`); |
| 164 | } |
| 165 | |
| 166 | visiting.add(itemName); |
| 167 | const item = await getItem(itemName); |
| 168 | for (const dep of item.registryDependencies ?? []) { |
| 169 | await visit(dep, [...path, itemName]); |
| 170 | } |
| 171 | visiting.delete(itemName); |
| 172 | visited.add(itemName); |
| 173 | ordered.push(item); |
| 174 | }; |
| 175 | |
| 176 | await visit(name, []); |
| 177 | return ordered; |
no test coverage detected