(actions: ActionProto[])
| 712 | } |
| 713 | |
| 714 | private checkCircularity(actions: ActionProto[]) { |
| 715 | const allActionsByStringifiedTarget = new Map<string, ActionProto>( |
| 716 | actions.map(action => [targetStringifier.stringify(action.target), action]) |
| 717 | ); |
| 718 | |
| 719 | // Type exports for tarjan-graph are unfortunately wrong, so we have to do this minor hack. |
| 720 | const tarjanGraph: TarjanGraph = new (TarjanGraphConstructor as any)(); |
| 721 | actions.forEach(action => { |
| 722 | // Declarations cannot have dependencies. |
| 723 | const cleanedDependencies = (action instanceof dataform.Declaration || |
| 724 | !action.dependencyTargets |
| 725 | ? [] |
| 726 | : action.dependencyTargets |
| 727 | ).filter( |
| 728 | dependency => !!allActionsByStringifiedTarget.get(targetStringifier.stringify(dependency)) |
| 729 | ); |
| 730 | tarjanGraph.add( |
| 731 | targetStringifier.stringify(action.target), |
| 732 | cleanedDependencies.map(target => targetStringifier.stringify(target)) |
| 733 | ); |
| 734 | }); |
| 735 | const cycles = tarjanGraph.getCycles(); |
| 736 | cycles.forEach(cycle => { |
| 737 | const firstActionInCycle = allActionsByStringifiedTarget.get(cycle[0].name); |
| 738 | const message = `Circular dependency detected in chain: [${cycle |
| 739 | .map(vertex => vertex.name) |
| 740 | .join(" > ")} > ${targetAsReadableString(firstActionInCycle.target)}]`; |
| 741 | this.compileError(new Error(message), firstActionInCycle.fileName, firstActionInCycle.target); |
| 742 | }); |
| 743 | } |
| 744 | |
| 745 | private addTestsToCompiledGraph(actions: Action[]) { |
| 746 | actions |
no test coverage detected