function registerLocalFilters(nunjucks, templateDir, filtersDir) {
  return new Promise((resolve, reject) => {
    const localFilters = path.resolve(templateDir, filtersDir);

    if (!fs.existsSync(localFilters)) return resolve();

    const walker = xfs.walk(localFilters, {
      followLinks: false
    });

    walker.on('file', async (root, stats, next) => {
      try {
        const filePath = path.resolve(
          templateDir,
          path.resolve(root, stats.name)
        );

        registerTypeScript(filePath);
        // If it's a module constructor, inject dependencies to ensure consistent usage in remote templates in other projects or plain directories.
        delete require.cache[require.resolve(filePath)];
        const mod = require(filePath);

        addFilters(nunjucks, mod);

        next();
      } catch (e) {
        reject(e);
      }
    });

    walker.on('errors', (root, nodeStatsArray) => {
      reject(nodeStatsArray);
    });

    walker.on('end', async () => {
      resolve();
    });
  });
}
Registers the local template 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 {String} filtersDir Directory where local filters are located.