<commit_before>When = require 'when'
{spawn} = require 'child_process'

{mixin} = require './utils'


module.exports = class Wrapper
  mixin this, require './args'
  mixin this, require './io'

  constructor: (source, bin) ->
    @_args = {_: []}
    @source = source
    @bin = bin || @constructor.bin

  _spawn: (args, stdin = false, stdout = false) ->
    {resolve, reject, promise} = When.defer()
    stderr = ''
    stdio = [
      if stdin  then 'pipe' else 'ignore'
      if stdout then 'pipe' else 'ignore'
      'pipe' # stderr
    ]
    proc = spawn @bin, args, {stdio}
    proc.once 'error', reject
    proc.once 'close', onClose = (code, signal) ->
      if code isnt 0 or signal isnt null<commit_msg>Fixed uninformative "spawn OK" error message on windows on<commit_after>When = require 'when'
{spawn} = require 'child_process'

{mixin} = require './utils'


module.exports = class Wrapper
  mixin this, require './args'
  mixin this, require './io'

  constructor: (source, bin) ->
    @_args = {_: []}
    @source = source
    @bin = bin || @constructor.bin

  _spawn: (args, stdin = false, stdout = false) ->
    {resolve, reject, promise} = When.defer()
    stderr = ''
    stdio = [
      if stdin  then 'pipe' else 'ignore'
      if stdout then 'pipe' else 'ignore'
      'pipe' # stderr
    ]
    proc = spawn @bin, args, {stdio}
    proc.once 'error', (err) ->
      reject err unless err.code is 'OK' is err.errno
    proc.once 'close', onClose = (code, signal) ->
      if code isnt 0 or signal isnt null
{'fraction_non_alphanumeric': 0.14407334643091027, 'fraction_numerical': 0.0013097576948264572, 'mean_word_length': 2.7359413202933984, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '1259881', 'n_tokens_mistral': 522, 'n_tokens_neox': 504, 'n_words': 167}