<commit_before>var Promise = require("bluebird"),
    childProcess = require('child_process');

var spawn = function(cmd, args, opts) {
  var resolve, reject, promise, child, output = [];

  promise = new Promise(function(res, rej) { resolve = res; reject = rej; });

  child = childProcess.spawn(cmd, args, opts);

  child.on('error', function(err) {
    return reject(err);
  });

  child.on('close', function(code) {
    if(code) return reject(code);
    return resolve(output.join("\n"));
  });

  child.stderr.setEncoding('utf8');
  child.stderr.on('data', console.error);

  if(opts && opts.logOutput) {
    child.stdout.setEncoding('utf8');
    child.stdout.on('data', console.log);
  }

  if(opts && opts.getOutput) {
    child.stdout.setEncoding('utf8');
    child.stdout.on('data', function(data) {
      output.push(data);
    });
  }

  return promise;
};

module.exports = spawn;<commit_msg>do not log stderr if option set<commit_after>var Promise = require("bluebird"),
    childProcess = require('child_process');

var spawn = function(cmd, args, opts) {
  var resolve, reject, promise, child, output = [];

  promise = new Promise(function(res, rej) { resolve = res; reject = rej; });

  child = childProcess.spawn(cmd, args, opts);

  child.on('error', function(err) {
    return reject(err);
  });

  child.on('close', function(code) {
    if(code) return reject(code);
    return resolve(output.join("\n"));
  });

  if(!opts || opts && opts.logError) {
    child.stderr.setEncoding('utf8');
    child.stderr.on('data', console.error);
  }

  if(opts && opts.logOutput) {
    child.stdout.setEncoding('utf8');
    child.stdout.on('data', console.log);
  }

  if(opts && opts.getOutput) {
    child.stdout.setEncoding('utf8');
    child.stdout.on('data', function(data) {
      output.push(data);
    });
  }

  return promise;
};

module.exports = spawn;
{'fraction_non_alphanumeric': 0.1793913507741591, 'fraction_numerical': 0.003203416978109984, 'mean_word_length': 3.768447837150127, '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': '5469445', 'n_tokens_mistral': 625, 'n_tokens_neox': 609, 'n_words': 122}