<commit_before>BufferedProcess = require './buffered-process'
path = require 'path'

# Public: Like BufferedProcess, but accepts a node script instead of an
# executable, on Unix which allows running scripts and executables, this seems
# unnecessary, but on Windows we have to separate scripts from executables since
# it doesn't support shebang strings.
module.exports =
class BufferedNodeProcess extends BufferedProcess
  constructor: ({command, args, options, stdout, stderr, exit}) ->
    node =
      if process.platform is 'darwin'
        # On OS X we use the helper process to run script, because it doesn't
        # create an icon on the Dock.
        path.resolve(process.resourcesPath, '..', 'Frameworks',
                     'Atom Helper.app', 'Contents', 'MacOS', 'Atom Helper')
      else
        process.execPath

    # Tell atom-shell to run like upstream node.
    options ?= {}
    options.env ?= Object.create(process.env)
    options.env['ATOM_SHELL_INTERNAL_RUN_AS_NODE'] = 1

    args.unshift(command)
    super({command: node, args, options, stdout, stderr, exit})
<commit_msg>:memo: Throughly document BufferedNodeProcess<commit_after>BufferedProcess = require './buffered-process'
path = require 'path'

# Public: Like {BufferedProcess}, but accepts a Node script instead of an
# executable.
#
# This may seem unnecessary but on Windows we have to have separate executables
# for each script without this since Windows doesn't support shebang strings.
module.exports =
class BufferedNodeProcess extends BufferedProcess
  # Executes the given Node script.
  #
  # * options
  #    + command:
  #      The path to the Javascript script to execute.
  #    + args:
  #      The array of arguments to pass to the script (optional).
  #    + options:
  #      The options Object to pass to Node's `ChildProcess.spawn` (optional).
  #    + stdout:
  #      The callback that receives a single argument which contains the
  #      standard output of the script. The callback is called as data is
  #      received but it's buffered to ensure only complete lines are passed
  #      until the source stream closes. After the source stream has closed
  #      all remaining data is sent in a final call (optional).
  #    + stderr:
  #      The callback that receives a single argument which contains the
  #      standard error of the script. The callback is called as data is
  #      received but it's buffered to ensure only complete lines are passed
  #      until the source stream closes. After the source stream has closed
  #      all remaining data is sent in a final call.
  #    + exit:
  #      The callback which receives a single argument containing the exit
  #      status (optional).
  constructor: ({command, args, options, stdout, stderr, exit}) ->
    node =
      if process.platform is 'darwin'
        # Use a helper to prevent an icon from appearing on the Dock
        path.resolve(process.resourcesPath, '..', 'Frameworks',
                     'Atom Helper.app', 'Contents', 'MacOS', 'Atom Helper')
      else
        process.execPath

    options ?= {}
    options.env ?= Object.create(process.env)
    options.env['ATOM_SHELL_INTERNAL_RUN_AS_NODE'] = 1

    args.unshift(command)
    super({command: node, args, options, stdout, stderr, exit})

{'fraction_non_alphanumeric': 0.08143421452446065, 'fraction_numerical': 0.0006077180188392585, 'mean_word_length': 3.069221260815822, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6323081', 'n_tokens_mistral': 905, 'n_tokens_neox': 876, 'n_words': 367}