<commit_before>/*
 * grunt-karma
 * https://github.com/karma-runner/grunt-karma
 *
 * Copyright (c) 2013 <NAME>
 * Licensed under the MIT license.
 */

var runner = require('karma').runner;
var server = require('karma').server;
var path = require('path');
var _ = require('lodash');

module.exports = function(grunt) {

  grunt.registerMultiTask('karma', 'run karma.', function() {
    var done = this.async();
    var options = this.options({
      background: false
    });

    if (!options.client) {
        options.client = {};
    }
    // Allow for passing cli arguments to `client.args` using  `--grep=x`
    var args = parseArgs(process.argv.slice(2));
    if (_.isArray(options.client.args)) {
        options.client.args = options.client.args.concat(args);
    } else {
        options.client.args = args;
    }

    // Merge karma default options
    _.defaults(options.client, {
        args: [],
        useIframe: true,
        captureConsole: true
    });

    var opts = _.cloneDeep(options);
    // Merge options onto data, with data taking precedence.
    var data = _.merge(opts, this.data);

    // But override the browsers array.
    if (data.browsers && this.data.browsers) {
      data.browsers = this.data.browsers;
    }

    // Merge client.args
    if (this.data.client && _.isArray(this.data.client.args)) {
        data.client.args = this.data.client.args.concat(options.client.args);
    }

    if (data.configFile) {
      data.configFile = path.resolve(data.configFile);
      data.configFile = grunt.template.process(data.configFile);
    }

    if (data.files){
      data.files = _.flatten(data.files);
    }

    // Allow the use of templates in preprocessors
    if (_.isPlainObject(data.preprocessors)) {
      var preprocessors = {};
      Object.keys(data.preprocessors).forEach(function (key) {<commit_msg>refactor(task): cleanup template processing<commit_after>/*
 * grunt-karma
 * https://github.com/karma-runner/grunt-karma
 *
 * Copyright (c) 2013 <NAME>
 * Licensed under the MIT license.
 */

var runner = require('karma').runner;
var server = require('karma').server;
var path = require('path');
var _ = require('lodash');

module.exports = function(grunt) {

  grunt.registerMultiTask('karma', 'run karma.', function() {
    var done = this.async();
    var options = this.options({
      background: false
    });

    if (!options.client) {
        options.client = {};
    }
    // Allow for passing cli arguments to `client.args` using  `--grep=x`
    var args = parseArgs(process.argv.slice(2));
    if (_.isArray(options.client.args)) {
        options.client.args = options.client.args.concat(args);
    } else {
        options.client.args = args;
    }

    // Merge karma default options
    _.defaults(options.client, {
        args: [],
        useIframe: true,
        captureConsole: true
    });

    var opts = _.cloneDeep(options);
    // Merge options onto data, with data taking precedence.
    var data = _.merge(opts, this.data);

    // But override the browsers array.
    if (data.browsers && this.data.browsers) {
      data.browsers = this.data.browsers;
    }

    // Merge client.args
    if (this.data.client && _.isArray(this.data.client.args)) {
        data.client.args = this.data.client.args.concat(options.client.args);
    }

    if (data.configFile) {
      data.configFile = path.resolve(data.configFile);
    }

    if (data.files){
      data.files = _.flatten(data.files);
    }

    // Allow the use of templates in preprocessors
    if (_.isPlainObject(data.preprocessors)) {
      var preprocessors = {};
      Object.keys(data.preprocessors).forEach(function (key) {
{'fraction_non_alphanumeric': 0.14496314496314497, 'fraction_numerical': 0.00273000273000273, 'mean_word_length': 2.6824120603015076, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '4699217', 'n_tokens_mistral': 1173, 'n_tokens_neox': 1144, 'n_words': 249}