function patternOptionsFromPlugin (plugin) {
  const config = {}

  // Expected keys for autoload plugin options that expect regexp patterns
  const patternOptionKeys = ['ignorePattern', 'indexPattern', 'autoHooksPattern']

  for (const key of patternOptionKeys) {
    const pattern = plugin[key]

    // If pattern key not found in plugin object, move on
    if (!pattern) {
      continue
    }

    // Build an instance of a RegExp. If this comes back undefined,
    // then an invalid value was provided. Move on.
    const regExpPattern = stringPatternToRegExp(pattern)
    if (!regExpPattern) {
      continue
    }

    // We have a valid RegExp so add the option to the config to pass along to
    // autoload.
    config[key] = regExpPattern
  }

  return config
}
Creates an object for pattern specific options. This ensures that
only configurations that have been provided are included in the
final result. This prevents 'cannot read properties of undefined'
errors when undefined configs are provided to the underlying
@fastify/autoload plugin.