Skip to content

Commit

Permalink
add the actual cycle to the build output
Browse files Browse the repository at this point in the history
  • Loading branch information
pawk3k committed Mar 21, 2024
1 parent db799c2 commit d542048
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/default-rules/circular-dependencies/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,14 @@ export const validateRegistries = (maybeRegistries: string | string[] | undefine
export const createNodeName = (node: string, commonPrefix: string): string =>
node.substring(commonPrefix.length, node.length) || commonPrefix;

const createUserOutput = (commonPrefix: string, cycleGraph: graphlib.Graph): string =>
`cyclic root folder: ${commonPrefix}${EOL}${dot.write(cycleGraph)}`;
const createUserOutput = (
commonPrefix: string,
cycleGraph: graphlib.Graph,
cycle: string[],
): string =>
`cyclic root folder: ${commonPrefix}${EOL}${dot.write(cycleGraph)}${EOL}Cycle:${cycle.join(
' -> ',
)}`;

const createMappedCycleMessage = (cycle: string[], mapping: Mapping, graph: graphlib.Graph) => {
const cycleGraph = new graphlib.Graph();
Expand Down Expand Up @@ -77,7 +83,7 @@ const createMappedCycleMessage = (cycle: string[], mapping: Mapping, graph: grap
);
});

return createUserOutput(commonPrefix, cycleGraph);
return createUserOutput(commonPrefix, cycleGraph, cycle);
};

const createCycleMessage = (cycle: string[], graph: graphlib.Graph) =>
Expand Down

0 comments on commit d542048

Please sign in to comment.