<commit_before>const temp = require('temp').track()
const fs = require('fs-extra')
const path = require('path')

const {CompositeDisposable} = require('event-kit')
const {watchPath, stopAllWatchers} = require('../lib')

process.on('unhandledRejection', r => console.log(r))

describe('exported functions', function () {
  let subs

  beforeEach(function () {
    subs = new CompositeDisposable()
  })

  afterEach(async function () {
    subs.dispose()
    await stopAllWatchers()
  })

  function tempMkdir (...args) {
    return new Promise((resolve, reject) => {
      temp.mkdir(...args, (err, dirPath) => {
        if (err) {
          reject(err)
        } else {
          resolve(dirPath)
        }
      })
    })
  }

  function waitForChanges (watcher, ...fileNames) {
    const waiting = new Set(fileNames)
    let fired = false
    const relevantEvents = []
<commit_msg>Explicitly clean up temp directories in afterEach<commit_after>const temp = require('temp').track()
const fs = require('fs-extra')
const path = require('path')

const {CompositeDisposable} = require('event-kit')
const {watchPath, stopAllWatchers} = require('../lib')

process.on('unhandledRejection', r => console.log(r))

describe('exported functions', function () {
  let subs

  beforeEach(function () {
    subs = new CompositeDisposable()
  })

  afterEach(async function () {
    subs.dispose()
    await stopAllWatchers()
    await tempCleanup()
  })

  function tempMkdir (...args) {
    return new Promise((resolve, reject) => {
      temp.mkdir(...args, (err, dirPath) => {
        if (err) {
          reject(err)
        } else {
          resolve(dirPath)
        }
      })
    })
  }

  function tempCleanup () {
    return new Promise((resolve, reject) => {
      temp.cleanup(err => {
        if (err) {
          reject(err)
        } else {
          resolve()
        }
      })
    })
  }

  function waitForChanges (watcher, ...fileNames) {
    const waiting = new Set(fileNames)
    let fired = false
    const relevantEvents = []

{'fraction_non_alphanumeric': 0.14629356897398135, 'fraction_numerical': 0.0, 'mean_word_length': 2.67870036101083, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '1259984', 'n_tokens_mistral': 636, 'n_tokens_neox': 624, 'n_words': 142}