Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
then(() => {
if (logFile) {
console.log(`Saving results in '${logFile}'...`);
console.log(`(LightHouse viewer: ${VIEWER_URL})`);
return printer.write(report, printer.OutputMode.json, logFile);
}
}).
then(() => {
async function processResults(results, minScores, logFile) {
const lhVersion = results.lhr.lighthouseVersion;
const categories = results.lhr.categories;
const report = results.report;
if (logFile) {
console.log(`\nSaving results in '${logFile}'...`);
console.log(` LightHouse viewer: ${VIEWER_URL}`);
await printer.write(report, printer.OutputMode.json, logFile);
}
console.log(`\nLighthouse version: ${lhVersion}`);
console.log('\nAudit results:');
const maxTitleLen = Math.max(...Object.values(categories).map(({title}) => title.length));
const success = Object.keys(categories).sort().reduce((aggr, cat) => {
const {title, score} = categories[cat];
const paddedTitle = `${title}:`.padEnd(maxTitleLen + 1);
const minScore = minScores[cat];
const passed = !isNaN(score) && (score >= minScore);
console.log(
` - ${paddedTitle} ${formatScore(score)} (Required: ${formatScore(minScore)}) ${passed ? 'OK' : 'FAILED'}`);
return aggr && passed;
return Printer.write(results.report, flags.output, outputPath).then(results => {
if (flags.output === Printer.OutputMode[Printer.OutputMode.html] ||
flags.output === Printer.OutputMode[Printer.OutputMode.domhtml]) {
if (flags.view) {
opn(outputPath, {wait: false});
} else {
log.log(
'CLI',
'Protip: Run lighthouse with `--view` to immediately open the HTML report in your browser');
}
}
return results;
});
}
return Printer.write(results.report, flags.output, outputPath).then(results => {
if (flags.output === Printer.OutputMode[Printer.OutputMode.html] ||
flags.output === Printer.OutputMode[Printer.OutputMode.domhtml]) {
if (flags.view) {
opn(outputPath, {wait: false});
} else {
log.log(
'CLI',
'Protip: Run lighthouse with `--view` to immediately open the HTML report in your browser');
}
}
return results;
});
}