Skip to content

Commit

Permalink
Migrate printer type names to be inline w/ core.
Browse files Browse the repository at this point in the history
  • Loading branch information
samccone committed Oct 21, 2016
1 parent ddd1a79 commit 5609403
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lighthouse-cli/printer.ts
Expand Up @@ -27,7 +27,7 @@ enum OutputMode { pretty, json, html };
type Mode = 'pretty' | 'json' | 'html';
const Modes = ['pretty', 'json', 'html'];

interface SubScore {
interface AuditResult {
displayValue: string;
debugString: string;
score: number;
Expand All @@ -38,16 +38,16 @@ interface SubScore {
};
}

interface Score {
interface AggregationResultItem {
overall: number;
name: string;
scored: boolean;
subItems: Array<SubScore | string>;
subItems: Array<AuditResult | string>;
}

interface Aggregation {
name: string;
score: Array<Score>;
score: Array<AggregationResultItem>;
}

interface Results {
Expand Down Expand Up @@ -88,7 +88,7 @@ function checkOutputPath(path: string): string {
return path;
}

function formatScore(score: boolean | number | string, suffix?: string) {
function formatAggregationResultItem(score: boolean | number | string, suffix?: string) {
// Until we only support node 6 we can not use default args.
suffix = suffix || '';

Expand Down Expand Up @@ -147,19 +147,19 @@ function createOutput(results: Results, outputMode: OutputMode): string {
const score = (item.overall * 100).toFixed(0);

if (item.name) {
output += `${bold}${item.name}${reset}: ${item.scored ? formatScore(score, '%') : ''}\n`;
output += `${bold}${item.name}${reset}: ${item.scored ? formatAggregationResultItem(score, '%') : ''}\n`;
}

item.subItems.forEach(subitem => {
let subscore: SubScore;
let subscore: AuditResult;

if (typeof subitem === 'string') {
subscore = results.audits[subitem as string];
} else {
subscore = subitem as SubScore;
subscore = subitem as AuditResult;
}

let lineItem = ` ── ${formatScore(subscore.score)} ${subscore.description}`;
let lineItem = ` ── ${formatAggregationResultItem(subscore.score)} ${subscore.description}`;
if (subscore.displayValue) {
lineItem += ` (${bold}${subscore.displayValue}${reset})`;
}
Expand Down

0 comments on commit 5609403

Please sign in to comment.