refactor(graph): the missing-dependency note is a string, not a callback
topoSort, finalizeGraph, assertNeedsSatisfiable and finalize all threaded a `(key: string) => string`, and no caller ever read `key` — the one producer, in prepareGraph, is `() => ...`. The note names which teapots did not connect, which does not vary by token, so the parameter was machinery for a customization nothing asked for. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
2 files changed
+7
-7
No files matched your search
+2
-2
@@ -43,7 +43,7 @@ export interface GraphNode {
|
||||
}
|
||||
|
||||
/** Orders nodes so every dependency precedes its dependents; throws on missing keys or cycles. */
|
||||
export function topoSort(nodes: GraphNode[], seedKeys: string[], note?: (key: string) => string): GraphNode[] {
|
||||
export function topoSort(nodes: GraphNode[], seedKeys: string[], note = ''): GraphNode[] {
|
||||
const producedBy = new Map<string, GraphNode>();
|
||||
for (const node of nodes) for (const key of node.provides) producedBy.set(key, node);
|
||||
|
||||
@@ -51,7 +51,7 @@ export function topoSort(nodes: GraphNode[], seedKeys: string[], note?: (key: st
|
||||
for (const node of nodes) {
|
||||
for (const key of node.needs) {
|
||||
if (!seedKeys.includes(key) && !producedBy.has(key)) {
|
||||
throw new Error(`missing dependency: ${key} needed by ${node.name}${note?.(key) ?? ''}`);
|
||||
throw new Error(`missing dependency: ${key} needed by ${node.name}${note}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user