(dag: BlockDependencyDag, blockMap: BlockMap)
| 495 | } |
| 496 | |
| 497 | function outputDot(dag: BlockDependencyDag, blockMap: BlockMap): void { |
| 498 | const lines: string[] = [] |
| 499 | |
| 500 | lines.push('digraph dependencies {') |
| 501 | lines.push(' rankdir=TB;') |
| 502 | lines.push(' node [shape=box, style=rounded];') |
| 503 | lines.push('') |
| 504 | |
| 505 | // Add nodes with labels |
| 506 | for (const node of dag.nodes) { |
| 507 | const info = blockMap.get(node.id) |
| 508 | const label = info?.label ?? node.id |
| 509 | const escapedLabel = label.replace(/"/g, '\\"') |
| 510 | const color = node.error ? 'red' : 'black' |
| 511 | lines.push(` "${node.id}" [label="${escapedLabel}", color=${color}];`) |
| 512 | } |
| 513 | |
| 514 | lines.push('') |
| 515 | |
| 516 | // Add edges |
| 517 | for (const edge of dag.edges) { |
| 518 | const vars = edge.inputVariables.join(', ') |
| 519 | const escapedVars = vars.replace(/"/g, '\\"') |
| 520 | lines.push(` "${edge.from}" -> "${edge.to}" [label="${escapedVars}"];`) |
| 521 | } |
| 522 | |
| 523 | lines.push('}') |
| 524 | |
| 525 | output(lines.join('\n')) |
| 526 | } |
| 527 | |
| 528 | function handleError(error: unknown, options: DagOptions): never { |
| 529 | if (error instanceof DagHandledError) { |
no test coverage detected