<commit_before>/*jshint node:true*/
var fs = require('fs'),
    path = require('path'),
    utils = require('../../lib/utils'),
    logger = require('winston').loggers.get('uiautomator'),
    dot = require('dot');

function Reporter(runner, options) {
    var me = this;
    if (!runner) {
        return;
    }
    me.runner = runner;
    me.options = options;
}

Reporter.prototype.process = function(stats, targetPath, callback) {
    var me = this;
    var tplFile = path.join(__dirname, '/junit.tpl');
    logger.profile('[junit reporter] process');
    fs.readFile(tplFile, function(err, data) {
        if (err) {
            logger.error('[junit reporter] could not read template file', tplFile);
            throw err;
        }
        me.createDirectory(targetPath, function(dir) {
            dot.templateSettings.strip = false;
            var tpl = dot.template(data.toString());
            // loop through each feature result
            utils.each(stats.results, function(result) {
                var output = tpl(result);
                var filename = path.join(dir, result.title + '.xml');
                fs.writeFile(filename, output, callback);
                logger.profile('[junit reporter] render');
            });
            logger.info('[junit reporter] generated junit report at %s', dir);
        });
    });
};

Reporter.prototype.createDirectory = function(target, cb) {
    var dir = path.join(process.cwd(), target, 'reports/junit');
    var tools = require('fs-tools');
    tools.remove(dir, function(err) {<commit_msg>Fixed path resolver in the junit reporter<commit_after>/*jshint node:true*/
var fs = require('fs'),
    path = require('path'),
    utils = require('../../lib/utils'),
    logger = require('winston').loggers.get('uiautomator'),
    dot = require('dot');

function Reporter(runner, options) {
    var me = this;
    if (!runner) {
        return;
    }
    me.runner = runner;
    me.options = options;
}

Reporter.prototype.process = function(stats, targetPath, callback) {
    var me = this;
    var tplFile = path.join(__dirname, '/junit.tpl');
    logger.profile('[junit reporter] process');
    fs.readFile(tplFile, function(err, data) {
        if (err) {
            logger.error('[junit reporter] could not read template file', tplFile);
            throw err;
        }
        me.createDirectory(targetPath, function(dir) {
            dot.templateSettings.strip = false;
            var tpl = dot.template(data.toString());
            // loop through each feature result
            utils.each(stats.results, function(result) {
                var output = tpl(result);
                var filename = path.join(dir, result.title + '.xml');
                fs.writeFile(filename, output, callback);
                logger.profile('[junit reporter] render');
            });
            logger.info('[junit reporter] generated junit report at %s', dir);
        });
    });
};

Reporter.prototype.createDirectory = function(target, cb) {
    var dir = path.resolve(process.cwd(), target, 'reports/junit');
    var tools = require('fs-tools');
    tools.remove(dir, function(err) {
{'fraction_non_alphanumeric': 0.14553543056879567, 'fraction_numerical': 0.0, 'mean_word_length': 2.447973713033954, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '5981178', 'n_tokens_mistral': 897, 'n_tokens_neox': 886, 'n_words': 214}