<commit_before>const { next, hookStart, hookEnd } = require('hooter/effects')
const assignDefaults = require('./assignDefaults')
const validateConfig = require('./validateConfig')


const EVENTS_WITH_CONFIG = ['start', 'execute', 'process', 'handle', 'error']


module.exports = function* configurePlugin() {
  let schema, config

  function* provideConfig(...args) {
    let event = this.type

    if (!config && event !== 'error') {
      throw new Error(
        `The config must already be defined at the beginning of "${event}"`
      )
    }

    return yield next(config, ...args)
  }

  yield hookEnd('schema', function* (_schema) {
    schema = yield next(_schema).or(_schema)
    return schema
  })

  yield hookStart('configure', function* (_config) {
    return yield next(schema, _config)
  })

  yield hookStart('configure', function* (_schema, _config) {
    _config = assignDefaults(_schema, _config)
    return yield next(_schema, _config)
  })

  yield hookEnd('configure', function* (_schema, _config) {
    validateConfig(_schema, _config)
    config = yield next(_schema, _config).or(_config)
    return config
  })

  for (let event of EVENTS_WITH_CONFIG) {
    yield hookStart(event, provideConfig)
  }
}
<commit_msg>Fix provideConfig() in configure using event.type instead of event.name<commit_after>const { next, hookStart, hookEnd } = require('hooter/effects')
const assignDefaults = require('./assignDefaults')
const validateConfig = require('./validateConfig')


const EVENTS_WITH_CONFIG = ['start', 'execute', 'process', 'handle', 'error']


module.exports = function* configurePlugin() {
  let schema, config

  function* provideConfig(...args) {
    let event = this.name

    if (!config && event !== 'error') {
      throw new Error(
        `The config must already be defined at the beginning of "${event}"`
      )
    }

    return yield next(config, ...args)
  }

  yield hookEnd('schema', function* (_schema) {
    schema = yield next(_schema).or(_schema)
    return schema
  })

  yield hookStart('configure', function* (_config) {
    return yield next(schema, _config)
  })

  yield hookStart('configure', function* (_schema, _config) {
    _config = assignDefaults(_schema, _config)
    return yield next(_schema, _config)
  })

  yield hookEnd('configure', function* (_schema, _config) {
    validateConfig(_schema, _config)
    config = yield next(_schema, _config).or(_config)
    return config
  })

  for (let event of EVENTS_WITH_CONFIG) {
    yield hookStart(event, provideConfig)
  }
}

{'fraction_non_alphanumeric': 0.13081166272655634, 'fraction_numerical': 0.0, 'mean_word_length': 3.8546845124282982, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '100792', 'n_tokens_mistral': 747, 'n_tokens_neox': 716, 'n_words': 210}