Skip to content

Commit 7aa7b3f

Browse files
aidenybaiamiagent
andcommitted
add box head face to score output, changes by score
Green (75+): happy ◠ ◠ / ▽ Yellow (50-74): concerned • • / ─ Red (<50): dead x x / ▽ Generated with [Ami](https://ami.dev) Co-Authored-By: Ami <noreply@ami.dev>
1 parent e2bbccb commit 7aa7b3f

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

packages/react-doctor/src/scan.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,25 @@ const printScoreGauge = (score: number, label: string): void => {
159159
logger.break();
160160
};
161161

162-
const printBranding = (): void => {
162+
const getDocterFace = (score: number): string[] => {
163+
if (score >= SCORE_GOOD_THRESHOLD) {
164+
return [" ┌─────┐", " │ ◠ ◠ │", " │ ▽ │", " └─────┘"];
165+
}
166+
if (score >= SCORE_OK_THRESHOLD) {
167+
return [" ┌─────┐", " │ • • │", " │ ─ │", " └─────┘"];
168+
}
169+
return [" ┌─────┐", " │ x x │", " │ ▽ │", " └─────┘"];
170+
};
171+
172+
const printBranding = (score?: number): void => {
163173
logger.break();
174+
if (score !== undefined) {
175+
const face = getDocterFace(score);
176+
for (const line of face) {
177+
logger.log(colorizeByScore(line, score));
178+
}
179+
logger.break();
180+
}
164181
logger.dim(" React Doctor (www.react.doctor)");
165182
};
166183

@@ -198,7 +215,7 @@ const printSummary = (
198215

199216
logger.log(` ${parts.join(" ")}`);
200217

201-
printBranding();
218+
printBranding(scoreResult?.score);
202219

203220
try {
204221
const diagnosticsDirectory = writeDiagnosticsDirectory(diagnostics);
@@ -298,7 +315,7 @@ export const scan = async (directory: string, options: ScanOptions): Promise<voi
298315
logger.break();
299316
if (scoreResult) {
300317
printScoreGauge(scoreResult.score, scoreResult.label);
301-
printBranding();
318+
printBranding(scoreResult.score);
302319
} else {
303320
logger.dim(` ${OFFLINE_MESSAGE}`);
304321
}

0 commit comments

Comments
 (0)