How to use the lighthouse/lighthouse-cli/printer.OutputMode function in lighthouse

To help you get started, we’ve selected a few lighthouse examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ngrx / platform / projects / ngrx.io / scripts / test-pwa-score.js View on Github external
then(() => {
      if (logFile) {
        console.log(`Saving results in '${logFile}'...`);
        console.log(`(LightHouse viewer: ${VIEWER_URL})`);

        return printer.write(report, printer.OutputMode.json, logFile);
      }
    }).
    then(() => {
github angular / angular / aio / scripts / audit-web-app.js View on Github external
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;
github addyosmani / webpack-lighthouse-plugin / src / lighthouse-bin.js View on Github external
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;
        });
      }
github addyosmani / webpack-lighthouse-plugin / src / lighthouse-bin.js View on Github external
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;
        });
      }