<commit_before>'use strict'

const debug = require('debug')
const log = debug('ipfsd-ctl:exec')
const path = require('path')
const execa = require('execa')
const noop = () => {}

function exec (cmd, args, opts, callback) {
  if (typeof opts === 'function') {
    callback = opts
    opts = {}
  }

  opts = Object.assign({}, {
    stdout: noop,
    stderr: noop
  }, opts)

  log(path.basename(cmd), args.join(' '))
  const command = execa(cmd, args, { env: opts.env })
  command.stderr.on('data', opts.stderr)
  command.stdout.on('data', opts.stdout)
  command
    .then(r => {
      callback(null, r)
    })
    .catch(err => {
      callback(err)
    })

  return command
}

module.exports = exec<commit_msg>fix: dont call callbacks twice<commit_after>'use strict'

const debug = require('debug')
const log = debug('ipfsd-ctl:exec')
const path = require('path')
const execa = require('execa')
const noop = () => {}

function exec (cmd, args, opts, callback) {
  if (typeof opts === 'function') {
    callback = opts
    opts = {}
  }

  opts = Object.assign({}, {
    stdout: noop,
    stderr: noop
  }, opts)

  log(path.basename(cmd), args.join(' '))
  const command = execa(cmd, args, { env: opts.env })
  command.stderr.on('data', opts.stderr)
  command.stdout.on('data', opts.stdout)
  command
    .then(r => {
      callback(null, r)
    }, err => {
      callback(err)
    })

  return command
}

module.exports = exec
{'fraction_non_alphanumeric': 0.17296918767507002, 'fraction_numerical': 0.0, 'mean_word_length': 3.1783625730994154, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '6841545', 'n_tokens_mistral': 496, 'n_tokens_neox': 485, 'n_words': 119}