<commit_before>// @flow

import chokidar from 'chokidar'
import type { ChangeCallback } from './'

export default class AdapterChokdiar {
  handle: Object
  rootDirectory: string
  constructor(rootDirectory: string, onChange: ChangeCallback) {
    this.rootDirectory = rootDirectory

    this.handle = chokidar.watch([], {
      ignoreInitial: true,
      awaitWriteFinish: {
        pollInterval: 30,
        stabilityThreshold: 60,
      },
    })
    this.handle.on('add', path => onChange('add', path, null))
    this.handle.on('unlink', path => onChange('delete', path, null))
    this.handle.on('change', path => onChange('modify', path, null))
  }
  watch(): Promise<void> {
    return new Promise(resolve => {
      this.handle.add(this.rootDirectory)
      this.handle.on('ready', resolve)
    })
  }
  close() {
    this.handle.close()
  }
}<commit_msg>:new: Ignore node_modules in chokidar<commit_after>// @flow

import chokidar from 'chokidar'
import type { ChangeCallback } from './'

export default class AdapterChokdiar {
  handle: Object
  rootDirectory: string
  constructor(rootDirectory: string, onChange: ChangeCallback) {
    this.rootDirectory = rootDirectory

    this.handle = chokidar.watch([], {
      ignored: [/(^|[\/\\])\../, /node_modules/],
      ignoreInitial: true,
      awaitWriteFinish: {
        pollInterval: 30,
        stabilityThreshold: 60,
      },
    })
    this.handle.on('add', path => onChange('add', path, null))
    this.handle.on('unlink', path => onChange('delete', path, null))
    this.handle.on('change', path => onChange('modify', path, null))
  }
  watch(): Promise<void> {
    return new Promise(resolve => {
      this.handle.add(this.rootDirectory)
      this.handle.on('ready', resolve)
    })
  }
  close() {
    this.handle.close()
  }
}
{'fraction_non_alphanumeric': 0.15222222222222223, 'fraction_numerical': 0.0044444444444444444, 'mean_word_length': 3.217798594847775, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '7056574', 'n_tokens_mistral': 571, 'n_tokens_neox': 569, 'n_words': 122}