Code coverage report for lib/error_page.js

Statements: 100% (10 / 10)      Branches: 50% (1 / 2)      Functions: 100% (1 / 1)      Lines: 100% (10 / 10)      Ignored: none     

All files » lib/ » error_page.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 3824 24   24       24                                   24 1 1 1   1           24  
var File = require('vinyl');
var ansiHTML = require('ansi-html');
 
var template = '<head><style>' +
  'body{padding:20px;font:18px monospace;background:#880000;color:#fff;}' +
  '</style></head>';
 
ansiHTML.setColors({
  reset: ['fff', '800'],
  black: 'aaa', // String
  red: '9ff',
  green: 'f9f',
  yellow: '99f',
  blue: 'ff9',
  magenta: 'f99',
  cyan: '9f9',
  lightgrey: 'ccc',
  darkgrey: 'aaa'
});
 
/**
 * 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();
  Eif (error.codeFrame) {
    errorText += '<pre>' + ansiHTML(error.codeFrame) + '</pre>';
  }
  return new File({
    path: 'index.html',
    contents: new Buffer(template + errorText)
  });
}
 
module.exports = errorPage;