<commit_before>'use babel';
import path from 'path';
import { EventEmitter } from 'events';
import { spawn } from 'child_process';
import ansi from 'ansi-html-stream';

/*globals
  atom
*/

class KarmaWrapper extends EventEmitter {
  constructor(context) {
    super();
    this.context = context;
    this.karma = null;
    this.node = atom.config.get('atom-karma-test-runner.nodeBinaryPath');
    this.env = atom.config.get('atom-karma-test-runner.env');
    this.reporter = atom.config.get('atom-karma-test-runner.karmaReporter');
  }

  run () {
    const env = {
      PATH: [process.env.PATH, path.dirname(this.node)].join(':')
    };
    const flags = [
      this.context.karma,
      "start",
      this.context.karmaConfig,
      "--single-run",
      `--reporters=${this.reporter}`,
    ];

    const options = {
      cwd: this.context.root,
      env: env
    };

    this.karma = spawn(this.node, flags, options);

    const handle = data => {
      return this.emit('output', data.toString());
    }

    const stream = ansi({chunked: false});
    this.karma.stdout.pipe(stream);
    this.karma.stderr.pipe(stream);
    stream.on('data', handle);

    return this.karma.on('exit', code => {
      if (code === 0) {
        return this.emit('success', this.stats);
      } else {
        return this.emit('failure', this.stats);
      }
    });
  }

}

export default KarmaWrapper;<commit_msg>there is no stats<commit_after>'use babel';
import path from 'path';
import { EventEmitter } from 'events';
import { spawn } from 'child_process';
import ansi from 'ansi-html-stream';

// context: { root, nodeBinary, env, karmaBinary, karmaConfig, karmaReporter};

class KarmaWrapper extends EventEmitter {
  constructor(context) {
    super();
    this.context = context;
    this.karma = null;
  }

  run () {
    const env = {
      PATH: [process.env.PATH, path.dirname(this.context.nodeBinary)].join(':')
    };
    const flags = [
      this.context.karmaBinary,
      "start",
      this.context.karmaConfig,
      "--single-run",
      `--reporters=${this.context.karmaReporter}`,
    ];

    const options = {
      cwd: this.context.root,
      env: env
    };
    this.karma = spawn(this.context.nodeBinary, flags, options);
    const handle = data => {
      return this.emit('output', data.toString());
    }

    const stream = ansi({chunked: false});
    this.karma.stdout.pipe(stream);
    this.karma.stderr.pipe(stream);
    stream.on('data', handle);

    return this.karma.on('exit', code => {
      if (code === 0) {
        return this.emit('success');
      } else {
        return this.emit('failure');
      }
    });
  }

}

export default KarmaWrapper;
{'fraction_non_alphanumeric': 0.15977653631284916, 'fraction_numerical': 0.0007448789571694599, 'mean_word_length': 2.7048275862068967, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4348597', 'n_tokens_mistral': 884, 'n_tokens_neox': 868, 'n_words': 177}