(node: string, path: string[])
| 46 | const cycle: string[] = []; |
| 47 | |
| 48 | const hasCycle = (node: string, path: string[]): boolean => { |
| 49 | if (recStack.has(node)) { |
| 50 | // Found a cycle - capture the cycle path |
| 51 | const cycleStart = path.indexOf(node); |
| 52 | cycle.push(...path.slice(cycleStart), node); |
| 53 | return true; |
| 54 | } |
| 55 | |
| 56 | if (visited.has(node)) { |
| 57 | return false; |
| 58 | } |
| 59 | |
| 60 | visited.add(node); |
| 61 | recStack.add(node); |
| 62 | |
| 63 | const deps = dependencies[node] || []; |
| 64 | for (const dep of deps) { |
| 65 | if (hasCycle(dep, [...path, node])) { |
| 66 | return true; |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | recStack.delete(node); |
| 71 | return false; |
| 72 | }; |
| 73 | |
| 74 | // Check each service for cycles |
| 75 | for (const service of Object.keys(dependencies)) { |
no test coverage detected