async function registerConfigHooks(hooks, templateDir, templateConfig) {
  const configHooks = templateConfig.hooks;
  const DEFAULT_MODULES_DIR = 'node_modules';

  if (typeof configHooks !== 'object' || !Object.keys(configHooks).length > 0) return;

  const promises = Object.keys(configHooks).map(async hooksModuleName => {
    let mod;
    try {
      //first we try to grab module with hooks by the module name
      //this is when generation is used on production using remote templates
      mod = require(hooksModuleName);
    } 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
      mod = require(path.resolve(templateDir, DEFAULT_MODULES_DIR, hooksModuleName));
    }
    const configHooksArray = [].concat(configHooks[hooksModuleName]);

    addHook(hooks, mod, configHooksArray);
  });
  await Promise.all(promises);
  return hooks;
}
Loads the template hooks provided in template config.
@private

@param {Object} hooks Object that stores information about all available hook functions grouped by the type of the hook.
@param {String} templateDir Directory where template is located.
@param {String} templateConfig Template configuration.