<commit_before>child_process = require 'child_process'
path = require 'path'
fs = require 'fs'
path = require 'path'
xcache = new Map
XRegExp = null
module.exports = Helpers =
  # Based on an API demoed out in:
  #   https://gist.github.com/steelbrain/43d9c38208bf9f2964ab

  exec: (command, args = [], options = {}) ->
    throw new Error "Nothing to execute." unless arguments.length
    return @_exec(command, args, options, false)

  execNode: (filePath, args = [], options = {}) ->
    throw new Error "Nothing to execute." unless arguments.length
    args.unshift(filePath)
    return @_exec(process.execPath, args, options, true)

  _exec: (command, args = [], options = {}, isNodeExecutable = false) ->
    options.stream ?= 'stdout'
    return new Promise (resolve, reject) ->
      if isNodeExecutable
        options.env ?= {}
        options.env.ATOM_SHELL_INTERNAL_RUN_AS_NODE = '1' # Needed for electron
        spawnedProcess = child_process.spawn(command, args, options)
      else
        spawnedProcess = child_process.spawn(command, args, options)
      data = []
      if options.stream is 'stdout'
        spawnedProcess.stdout.on 'data', (d) -> data.push(d.toString())
      else if options.stream is 'stderr'
        spawnedProcess.stderr.on 'data', (d) -> data.push(d.toString())<commit_msg>:art: Simplify execNode a bit<commit_after>child_process = require 'child_process'
path = require 'path'
fs = require 'fs'
path = require 'path'
xcache = new Map
XRegExp = null
module.exports = Helpers =
  # Based on an API demoed out in:
  #   https://gist.github.com/steelbrain/43d9c38208bf9f2964ab

  exec: (command, args = [], options = {}) ->
    throw new Error "Nothing to execute." unless arguments.length
    return @_exec(command, args, options, false)

  execNode: (filePath, args = [], options = {}) ->
    throw new Error "Nothing to execute." unless arguments.length
    args.unshift(filePath)
    return @_exec(process.execPath, args, options, true)

  _exec: (command, args = [], options = {}, isNodeExecutable = false) ->
    options.stream ?= 'stdout'
    return new Promise (resolve, reject) ->
      if isNodeExecutable
        options.env ?= {}
        options.env.ATOM_SHELL_INTERNAL_RUN_AS_NODE = '1' # Needed for electron
      spawnedProcess = child_process.spawn(command, args, options)
      data = []
      if options.stream is 'stdout'
        spawnedProcess.stdout.on 'data', (d) -> data.push(d.toString())
      else if options.stream is 'stderr'
        spawnedProcess.stderr.on 'data', (d) -> data.push(d.toString())
{'fraction_non_alphanumeric': 0.12870514820592824, 'fraction_numerical': 0.0109204368174727, 'mean_word_length': 3.3622448979591835, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '2084584', 'n_tokens_mistral': 815, 'n_tokens_neox': 804, 'n_words': 218}