Skip to content

Commit

Permalink
Set subitem type to match the mixed type.
Browse files Browse the repository at this point in the history
  • Loading branch information
samccone committed Oct 21, 2016
1 parent b11db43 commit 8465db3
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions lighthouse-cli/printer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ interface Score {
overall: number;
name: string;
scored: boolean;
subItems: Array<SubScore>;
subItems: Array<SubScore | string>;
}

interface Aggregation {
Expand Down Expand Up @@ -136,23 +136,27 @@ function createOutput(results: Results, outputMode: OutputMode): string {
}

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

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

let lineItem = ` ── ${formatScore(subitem.score)} ${subitem.description}`;
if (subitem.displayValue) {
lineItem += ` (${bold}${subitem.displayValue}${reset})`;
let lineItem = ` ── ${formatScore(subscore.score)} ${subscore.description}`;
if (subscore.displayValue) {
lineItem += ` (${bold}${subscore.displayValue}${reset})`;
}
output += `${lineItem}\n`;
if (subitem.debugString) {
output += ` ${subitem.debugString}\n`;
if (subscore.debugString) {
output += ` ${subscore.debugString}\n`;
}

if (subitem.extendedInfo && subitem.extendedInfo.value) {
if (subscore.extendedInfo && subscore.extendedInfo.value) {
const formatter =
Formatter.getByName(subitem.extendedInfo.formatter).getFormatter('pretty');
output += `${formatter(subitem.extendedInfo.value)}`;
Formatter.getByName(subscore.extendedInfo.formatter).getFormatter('pretty');
output += `${formatter(subscore.extendedInfo.value)}`;
}
});

Expand Down

0 comments on commit 8465db3

Please sign in to comment.