Write HTML output by default.
This commit is contained in:
Родитель
8f157e21e7
Коммит
c9ab75dca6
|
@ -9,4 +9,5 @@ artifacts.log
|
|||
coverage
|
||||
|
||||
results.html
|
||||
last-run-results.html
|
||||
.vscode
|
||||
|
|
|
@ -100,11 +100,12 @@ if (!flags.auditWhitelist || flags.auditWhitelist === 'all') {
|
|||
|
||||
// kick off a lighthouse run
|
||||
lighthouseModule(url, flags)
|
||||
.then(results => Printer.write(results, outputMode, outputPath))
|
||||
.then(results => {
|
||||
return Printer.write(results, outputMode, outputPath);
|
||||
})
|
||||
.then(status => {
|
||||
outputPath !== 'stdout' && log.info('printer', status);
|
||||
if (outputMode !== 'html') {
|
||||
Printer.write(results, 'html', './last-run-results.html');
|
||||
}
|
||||
return;
|
||||
})
|
||||
.catch(err => {
|
||||
if (err.code === 'ECONNREFUSED') {
|
||||
|
|
|
@ -101,10 +101,6 @@ function createOutput(results, outputMode) {
|
|||
output += ` ${subitem.debugString}\n`;
|
||||
}
|
||||
|
||||
if (subitem.extendedInfo && !subitem.extendedInfo.formatter) {
|
||||
log.log('warn', 'CLI formatter not provided', JSON.stringify(subitem.extendedInfo));
|
||||
}
|
||||
|
||||
if (subitem.extendedInfo && subitem.extendedInfo.value) {
|
||||
const formatter =
|
||||
Formatter.getByName(subitem.extendedInfo.formatter).getFormatter('pretty');
|
||||
|
@ -125,7 +121,7 @@ function createOutput(results, outputMode) {
|
|||
* @return {!Promise}
|
||||
*/
|
||||
function writeToStdout(output) {
|
||||
return Promise.resolve(process.stdout.write(`${output}\n`));
|
||||
return process.stdout.write(`${output}\n`);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -133,18 +129,17 @@ function writeToStdout(output) {
|
|||
*
|
||||
* @param {string} filePath The destination path
|
||||
* @param {string} output The output to write
|
||||
* @param {string} outputMode Output mode; either 'pretty', 'json', or 'html'.
|
||||
* @return {Promise}
|
||||
*/
|
||||
function writeFile(filePath, output) {
|
||||
return new Promise((resolve, reject) => {
|
||||
function writeFile(filePath, output, outputMode) {
|
||||
// TODO: make this mkdir to the filePath.
|
||||
fs.writeFile(filePath, output, 'utf8', err => {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
throw err;
|
||||
}
|
||||
|
||||
resolve(`Output written to ${filePath}`);
|
||||
});
|
||||
log.info('printer', `${outputMode} output written to ${filePath}`);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -157,16 +152,20 @@ function writeFile(filePath, output) {
|
|||
* @return {!Promise}
|
||||
*/
|
||||
function write(results, mode, path) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const outputMode = checkOutputMode(mode);
|
||||
const outputPath = checkOutputPath(path);
|
||||
|
||||
const output = createOutput(results, outputMode);
|
||||
|
||||
if (outputPath === 'stdout') {
|
||||
return writeToStdout(output);
|
||||
writeToStdout(output);
|
||||
return resolve(results);
|
||||
}
|
||||
|
||||
return writeFile(outputPath, output);
|
||||
writeFile(outputPath, output, outputMode);
|
||||
return resolve(results);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
|
|
@ -29,11 +29,7 @@ class Accessibilty extends Formatter {
|
|||
return function(info) {
|
||||
let output = ` - Rating: ${info.impact}\n` +
|
||||
` - See: ${info.helpUrl}\n` +
|
||||
' - Nodes:\n' +
|
||||
info.nodes.reduce((prev, node) => {
|
||||
return prev + ` - ${node.target}\n`;
|
||||
}, '');
|
||||
|
||||
` - Nodes: ${info.nodes.length} nodes identified (see HTML output for details)\n`;
|
||||
return output;
|
||||
};
|
||||
|
||||
|
|
|
@ -180,10 +180,9 @@ class ReportGenerator {
|
|||
return;
|
||||
}
|
||||
if (!subItem.extendedInfo.formatter) {
|
||||
log.log('warn', 'HTML formatter not provided', JSON.stringify(subItem.extendedInfo));
|
||||
// HTML formatter not provided for this subItem
|
||||
return;
|
||||
}
|
||||
|
||||
const formatter = Formatter.getByName(subItem.extendedInfo.formatter);
|
||||
const helpers = formatter.getHelpers();
|
||||
if (helpers) {
|
||||
|
|
|
@ -38,8 +38,8 @@ class ManifestDisplay extends Audit {
|
|||
* @override
|
||||
*/
|
||||
static get description() {
|
||||
return `Manifest's display property set to standalone/fullscreen to
|
||||
allow launching without address bar`;
|
||||
return 'Manifest\'s display property set to standalone/fullscreen to ' +
|
||||
'allow launching without address bar';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче