documentation/lib/error_page.js
Tom MacWright 50aaf9d35b --watch and --serve flags
These new flags replace the functionality of
dev-documentation
2015-11-24 11:21:11 -05:00

26 lines
676 B
JavaScript

var File = require('vinyl');
var ansiHTML = require('ansi-html');
var template = '<head><style>' +
'body{padding:20px;font:16px monospace;background:#CC0000;color:#fff;}' +
'pre{background:#fff}' +
'</style></head>';
/**
* Given an error, generate an HTML page that represents the error.
* @param {Error} error parse or generation error
* @returns {Object} vinyl file object
*/
function errorPage(error) {
var errorText = error.toString();
if (error.codeFrame) {
errorText += '<pre>' + ansiHTML(error.codeFrame) + '</pre>';
}
return new File({
path: 'index.html',
contents: new Buffer(template + errorText)
});
}
module.exports = errorPage;