<commit_before>var Command = require('./Command');
var _super = Command.prototype;
var child_process = require('child_process');
var npath = require('path');

module.exports = Command.extend({

  'initialize': function () {

    var self = this;
    _super.initialize.apply(self, arguments);

    self.ensureAsimovProject().done(function () {

      self.logAsimovHeader();
      self.logger.pending(self.namespace, 'Running tests for "' + self.options.meta.name +'" ' + self.options.meta.version);

      var commandIndex = self.options.args.indexOf('test');
      var grep = self.options.args[commandIndex + 1];

      var reporterFlagIndex = self.options.args.indexOf('-R');
      if (reporterFlagIndex === commandIndex + 1) grep = null;

      // var reporterFlagIndex = self.options.args.indexOf('-R');

      var path = npath.resolve(__dirname, '../../node_modules/mocha/bin/mocha');
      var paths = self.getTestPaths(null, grep, []);
      if (paths.length) {
        var child = child_process.fork(path, paths);
        child.on('exit', function (code) {
          self.filesystem.recursiveDelete(npath.join(process.cwd(), 'tests/temp'));
          process.exit(code);
        });
      }
    });
  },

  'getTestPaths': function (path, grep, paths) {

    var self = this;
    if (!grep) return ['tests/**/*.test.js'];

    paths = paths || [];
    path = path || npath.join(process.cwd(), 'tests');

    self.filesystem.readDirectory(path, function (subPath) {<commit_msg>use different test reporters with -R [name]<commit_after>var Command = require('./Command');
var _super = Command.prototype;
var child_process = require('child_process');
var npath = require('path');

module.exports = Command.extend({

  'initialize': function () {

    var self = this;
    _super.initialize.apply(self, arguments);

    self.ensureAsimovProject().done(function () {

      self.logAsimovHeader();
      self.logger.pending(self.namespace, 'Running tests for "' + self.options.meta.name +'" ' + self.options.meta.version);

      var commandIndex = self.options.args.indexOf('test');
      var grep = self.options.args[commandIndex + 1];

      var reporterFlagIndex = self.options.args.indexOf('-R');
      if (reporterFlagIndex === commandIndex + 1) grep = null;
      var reporterFlag = ~reporterFlagIndex && self.options.args[reporterFlagIndex + 1];

      var path = npath.resolve(__dirname, '../../node_modules/mocha/bin/mocha');
      var flags = self.getTestPaths(null, grep, []);

      if (reporterFlag) {
        flags = flags.concat(['-R', reporterFlag]);
      }

      if (flags.length) {
        var child = child_process.fork(path, flags);
        child.on('exit', function (code) {
          self.filesystem.recursiveDelete(npath.join(process.cwd(), 'tests/temp'));
          process.exit(code);
        });
      }
    });
  },

  'getTestPaths': function (path, grep, paths) {

    var self = this;
    if (!grep) return ['tests/**/*.test.js'];

    paths = paths || [];
    path = path || npath.join(process.cwd(), 'tests');

    self.filesystem.readDirectory(path, function (subPath) {
{'fraction_non_alphanumeric': 0.16473616473616473, 'fraction_numerical': 0.0016087516087516086, 'mean_word_length': 3.1343085106382977, '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': '73158', 'n_tokens_mistral': 969, 'n_tokens_neox': 924, 'n_words': 191}