<commit_before>// @flow

import Hooks from './hooks'
import {buildConfig} from 'cli-engine-config'

let init = (options = {}) => {
  process.env.RAN_HOOK = '0'
  let config = buildConfig(options)
  return new Hooks({config})
}

test('does not error when no hooks', async () => {
  let hooks = init()
  await hooks.run('prerun')
})

test('fires a hook', async () => {
  let hooks = init({
    root: process.cwd(),
    hooks: {
      prerun: 'test/fixtures/hooks/prerun.js'
    }
  })
  await hooks.run('prerun')
  expect(process.env.RAN_HOOK).toEqual('1')
})<commit_msg>multiple hooks<commit_after>// @flow

import Hooks from './hooks'
import {buildConfig} from 'cli-engine-config'

let init = (options = {}) => {
  process.env.RAN_HOOK = '0'
  let config = buildConfig(options)
  return new Hooks({config})
}

test('does not error when no hooks', async () => {
  let hooks = init()
  await hooks.run('prerun')
})

test('fires a hook', async () => {
  let hooks = init({
    root: process.cwd(),
    hooks: {
      prerun: [
        'test/fixtures/hooks/prerun.js'
      ]
    }
  })
  await hooks.run('prerun')
  expect(process.env.RAN_HOOK).toEqual('1')
})
{'fraction_non_alphanumeric': 0.1780466724286949, 'fraction_numerical': 0.003457216940363008, 'mean_word_length': 3.2888888888888888, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '3171564', 'n_tokens_mistral': 418, 'n_tokens_neox': 425, 'n_words': 97}