Skip to content

Commit

Permalink
refactor: tweaks output
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjastrzebski committed Jun 16, 2024
1 parent e58efac commit d6676dd
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/compare/src/output/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,25 +208,25 @@ function buildRenderIssuesList(issues: RenderIssues | undefined) {

const output = ['Render issues:'];
if (issues?.initialUpdateCount) {
output.push(` - Initial updates: ${formatInitialUpdates(issues.initialUpdateCount)}`);
output.push(` - Initial updates: ${formatInitialUpdates(issues.initialUpdateCount, false)}`);
}
if (issues?.redundantUpdates) {
output.push(` - Redundant updates: ${formatRedundantUpdates(issues.redundantUpdates)}`);
if (issues?.redundantUpdates?.length) {
output.push(` - Redundant updates: ${formatRedundantUpdates(issues.redundantUpdates, false)}`);
}

return output.join('<br/>');
}

function formatInitialUpdates(count: number | undefined) {
function formatInitialUpdates(count: number | undefined, showSymbol: boolean = true) {
if (count == null) return '?';
if (count === 0) return '-';

return `${count} 🔴`;
return `${count}${showSymbol ? ' 🔴' : ''}`;
}

function formatRedundantUpdates(redundantUpdates: number[] | undefined) {
function formatRedundantUpdates(redundantUpdates: number[] | undefined, showSymbol: boolean = true) {
if (redundantUpdates == null) return '?';
if (redundantUpdates.length === 0) return '-';

return `${redundantUpdates.length} (${redundantUpdates.join(', ')}) 🔴`;
return `${redundantUpdates.length} (${redundantUpdates.join(', ')})${showSymbol ? ' 🔴' : ''}`;
}

0 comments on commit d6676dd

Please sign in to comment.