<commit_before>var util = require('util'),
    fs   = require('fs'),
    path = require('path'),
    mocha = require('mocha'),
    _ = require('lodash'),
    handlebars = require('handlebars'),
    moment = require('moment'),
    less = require('less');

var Base = mocha.reporters.Base,
    utils = mocha.utils,
    cursor = Base.cursor,
    color = Base.color;

var reportsDir = path.join(process.cwd(), 'reports'),
    reportJsonFile = path.join(reportsDir, 'reports.json'),
    reportHtmlFile = path.join(reportsDir, 'mochawesome.html');
    reportCssFile = path.join(reportsDir, 'mochawesome.css');

module.exports = Mochawesome;

createStylesheet();

// Load templates
// TODO: load all files in templates directory instead of specific ones
var mochawesomeReport = fs.readFileSync(path.join(__dirname, '..', 'templates', 'mochawesome.mu'), {
  encoding: 'utf8'
});

var _summary = fs.readFileSync(path.join(__dirname, '..', 'templates', '_summary.mu'), {
  encoding: 'utf8'
});

var _suite = fs.readFileSync(path.join(__dirname, '..', 'templates', '_suite.mu'), {
  encoding: 'utf8'
});

var _test = fs.readFileSync(path.join(__dirname, '..', 'templates', '_test.mu'), {
  encoding: 'utf8'
});

// TODO: if filename begins with underscore, register it as a partial
handlebars.registerPartial('_summary', _summary);
handlebars.registerPartial('_suite', _suite);
handlebars.registerPartial('_test', _test);

// Compile template
var mochawesomeReportTmp = handlebars.compile(mochawesomeReport);


/**
 * Initialize a new reporter.
 *
 * @param {Runner} runner
 * @api public
 */

function Mochawesome (runner) {
  var self = this;
  Base.call(this, runner);

  var allSuites = {},<commit_msg>load templates async<commit_after>var util = require('util'),
    fs   = require('fs'),
    path = require('path'),
    mocha = require('mocha'),
    _ = require('lodash'),
    handlebars = require('handlebars'),
    moment = require('moment'),
    less = require('less');

var Base = mocha.reporters.Base,
    utils = mocha.utils,
    cursor = Base.cursor,
    color = Base.color;

var reportsDir = path.join(process.cwd(), 'reports'),
    reportJsonFile = path.join(reportsDir, 'reports.json'),
    reportHtmlFile = path.join(reportsDir, 'mochawesome.html');
    reportCssFile = path.join(reportsDir, 'mochawesome.css'),
    templatesDir = path.join(__dirname, '..', 'templates'),
    templates = {};

module.exports = Mochawesome;

createStylesheet();

// Load templates
// TODO: load all files in templates directory instead of specific ones

fs.readdir(templatesDir, function (err, files) {
  if (err) throw err;
  files.forEach(function (file) {
    var filePath = path.join(templatesDir, file);
    fs.readFile(filePath, {encoding:'utf8'}, function (err, data) {
      if (err) throw err;
      if (file.indexOf('_') === 0) {
        handlebars.registerPartial(file, data);
      } else {
        templates[file] = handlebars.compile(data);
      }
    });
  });
});

// var mochawesomeReport = fs.readFileSync(path.join(__dirname, '..', 'templates', 'mochawesome.mu'), {
//   encoding: 'utf8'
// });

// var _summary = fs.readFileSync(path.join(__dirname, '..', 'templates', '_summary.mu'), {
//   encoding: 'utf8'
// });

// var _suite = fs.readFileSync(path.join(__dirname, '..', 'templates', '_suite.mu'), {
//   encoding: 'utf8'
// });

// var _test = fs.readFileSync(path.join(__dirname, '..', 'templates', '_test.mu'), {
//   encoding: 'utf8'
// });

// // TODO: if filename begins with underscore, register it as a partial
// handlebars.registerPartial('_summary', _summary);
// handlebars.registerPartial('_suite', _suite);
// handlebars.registerPartial('_test', _test);

// // Compile template
// var mochawesomeReportTmp = handlebars.compile(mochawesomeReport);


/**
 * Initialize a new reporter.
 *
 * @param {Runner} runner
 * @api public
 */

function Mochawesome (runner) {
  var self = this;
  Base.call(this, runner);

  var allSuites = {},
{'fraction_non_alphanumeric': 0.17146464646464646, 'fraction_numerical': 0.0025252525252525255, 'mean_word_length': 3.932752179327522, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1114789', 'n_tokens_mistral': 1287, 'n_tokens_neox': 1269, 'n_words': 283}