<commit_before>EventEmitter = Npm.require('events').EventEmitter
Path = Npm.require('path')
fs = Npm.require('fs')
Future = Npm.require('fibers/future')
spawn = Npm.require('child_process').spawn
shelljs = Npm.require('shelljs')
chokidar = Npm.require('chokidar')

syncExec = Meteor._wrapAsync(shelljs.exec)

#
# Repository with file system event notification so we can publish changes.
#
# Mainly this is concerned with maintaining the file list. We want to use a
# simple meteor collection, so it has to be a linear view rather than a tree.
#
class Repo extends EventEmitter
  constructor: (@repoPath) ->
    self = this

    watcher = chokidar.watch(@repoPath,
      ignored: /\/\.git/,
      ignoreInitial: true)

    watcher.on 'add',<commit_msg>init repo on create, if it's not already a repo<commit_after>EventEmitter = Npm.require('events').EventEmitter
Path = Npm.require('path')
fs = Npm.require('fs')
Future = Npm.require('fibers/future')
spawn = Npm.require('child_process').spawn
shelljs = Npm.require('shelljs')
chokidar = Npm.require('chokidar')

syncExec = Meteor._wrapAsync(shelljs.exec)

#
# Repository with file system event notification so we can publish changes.
#
# Mainly this is concerned with maintaining the file list. We want to use a
# simple meteor collection, so it has to be a linear view rather than a tree.
#
class Repo extends EventEmitter
  constructor: (@repoPath) ->
    self = this

    unless fs.existsSync(Path.join(@repoPath, '.git'))
      @spawnInRepoPath 'git', ['init']

    watcher = chokidar.watch(@repoPath,
      ignored: /\/\.git/,
      ignoreInitial: true)

    watcher.on 'add',
{'fraction_non_alphanumeric': 0.1220110361741263, 'fraction_numerical': 0.0, 'mean_word_length': 4.197452229299363, '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': '6063125', 'n_tokens_mistral': 524, 'n_tokens_neox': 516, 'n_words': 158}