MCPcopy Create free account
hub / github.com/code-pushup/cli / applyScoreColor

Function applyScoreColor

packages/utils/src/lib/reports/utils.ts:291–312  ·  view source on GitHub ↗
(
  { score, text }: { score: number; text?: string },
  style: Ansis = ansis,
)

Source from the content-addressed store, hash-verified

289
290// @TODO rethink implementation
291export function applyScoreColor(
292 { score, text }: { score: number; text?: string },
293 style: Ansis = ansis,
294) {
295 const formattedScore = text ?? formatReportScore(score);
296
297 if (score >= SCORE_COLOR_RANGE.GREEN_MIN) {
298 return text
299 ? style.green(formattedScore)
300 : style.bold(style.green(formattedScore));
301 }
302
303 if (score >= SCORE_COLOR_RANGE.YELLOW_MIN) {
304 return text
305 ? style.yellow(formattedScore)
306 : style.bold(style.yellow(formattedScore));
307 }
308
309 return text
310 ? style.red(formattedScore)
311 : style.bold(style.red(formattedScore));
312}
313
314export function scoreTargetIcon(
315 score: number,

Callers 3

logAuditsFunction · 0.85
logCategoriesFunction · 0.85
utils.unit.test.tsFile · 0.85

Calls 1

formatReportScoreFunction · 0.85

Tested by

no test coverage detected