Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return promise.then(_ => {
if (Array.isArray(flags.output)) {
return flags.output.reduce((innerPromise, outputType) => {
const outputPath = `${resolvedPath}.report.${typeToExtension(outputType)}`;
return innerPromise.then((_) => Printer.write(results, outputType, outputPath));
}, Promise.resolve(results));
} else {
const outputPath =
flags.outputPath || `${resolvedPath}.report.${typeToExtension(flags.output)}`;
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 innerPromise.then((_) => Printer.write(results, outputType, outputPath));
}, Promise.resolve(results));