async function registerConfigFilters(nunjucks, templateDir, templateConfig) {
  const confFilters = templateConfig.filters;
  const DEFAULT_MODULES_DIR = 'node_modules';
  if (!Array.isArray(confFilters)) return;

  const promises = confFilters.map(async filtersModule => {
    let mod;
    let filterName = filtersModule;
    try {
      //first we try to grab module with filters by the module name
      //this is when generation is used on production using remote templates
      mod = require(filterName);
    } catch (error) {
      //in case template is local but was not installed in node_modules of the generator then we need to explicitly provide modules location
      try {
        filterName = path.resolve(templateDir, DEFAULT_MODULES_DIR, filtersModule);
        mod = require(filterName);
      } catch (e) {
        //sometimes it may happen that template is located in node_modules with other templates and its filter package is on the same level as template, as it is shared with other templates
        try {
          filterName = path.resolve(templateDir, '../..', filtersModule);
          mod = require(filterName);
        } catch (error) {
          //in rare cases, especially in isolated tests, it may happen that installation
          //ends but is not yet fully completed, so initial require of the same path do not work
          //but in next attempt it works
          //we need to keep this workaround until we find a solution
          mod = require(filterName);
        }
      }
    }
    return addFilters(nunjucks, mod);
  });

  await Promise.all(promises);
}
Registers the additionally configured filters.
@deprecated This method is deprecated. For more details, see the release notes: https://github.com/asyncapi/generator/releases/tag/%40asyncapi%2Fgenerator%402.6.0
@private
@param {Object} nunjucks Nunjucks environment.
@param {String} templateDir Directory where template is located.
@param {Object} templateConfig Template configuration.