lib/config.js
function getPluginsConfig(pluginNames) {
  var pluginConfig = {};

  pluginNames.forEach(function(pluginName) {
    var pluginNamespace = util.getNamespace(pluginName),
      pluginNameWithoutNamespace = util.removeNameSpace(pluginName),
      pluginNameWithoutPrefix = util.removePluginPrefix(pluginNameWithoutNamespace),
      plugin = {},
      rules = {};

    if (!loadedPlugins[pluginNameWithoutPrefix]) {
      try {
        plugin = require(pluginNamespace + util.PLUGIN_NAME_PREFIX + pluginNameWithoutPrefix);
        loadedPlugins[pluginNameWithoutPrefix] = plugin;
      } catch (err) {
        plugin = { rulesConfig: {}};
      }
    } else {
      plugin = loadedPlugins[pluginNameWithoutPrefix];
    }

    if (!plugin.rulesConfig) {
      plugin.rulesConfig = {};
    }

    Object.keys(plugin.rulesConfig).forEach(function(item) {
      rules[pluginNameWithoutPrefix + '/' + item] = plugin.rulesConfig[item];
    });

    pluginConfig = util.mergeConfigs(pluginConfig, rules);
  });

  return {rules: pluginConfig};
}
function getPluginsConfig(pluginNames) {
  var pluginConfig = {};

  pluginNames.forEach(function(pluginName) {
    var pluginNamespace = util.getNamespace(pluginName),
      pluginNameWithoutNamespace = util.removeNameSpace(pluginName),
      pluginNameWithoutPrefix = util.removePluginPrefix(pluginNameWithoutNamespace),
      plugin = {},
      rules = {};

    if (!loadedPlugins[pluginNameWithoutPrefix]) {
      try {
        plugin = require(pluginNamespace + util.PLUGIN_NAME_PREFIX + pluginNameWithoutPrefix);
        loadedPlugins[pluginNameWithoutPrefix] = plugin;
      } catch (err) {
        plugin = { rulesConfig: {}};
      }
    } else {
      plugin = loadedPlugins[pluginNameWithoutPrefix];
    }

    if (!plugin.rulesConfig) {
      plugin.rulesConfig = {};
    }

    Object.keys(plugin.rulesConfig).forEach(function(item) {
      rules[pluginNameWithoutPrefix + '/' + item] = plugin.rulesConfig[item];
    });

    pluginConfig = util.mergeConfigs(pluginConfig, rules);
  });

  return {rules: pluginConfig};
}
function getPluginsConfig ( pluginNames ) { var pluginConfig = { } ; pluginNames . forEach ( function ( pluginName ) { var pluginNamespace = util . getNamespace ( pluginName ) , pluginNameWithoutNamespace = util . removeNameSpace ( pluginName ) , pluginNameWithoutPrefix = util . removePluginPrefix ( pluginNameWithoutNamespace ) , plugin = { } , rules = { } ; if ( ! loadedPlugins [ pluginNameWithoutPrefix ] ) { try { plugin = require ( pluginNamespace + util . PLUGIN_NAME_PREFIX + pluginNameWithoutPrefix ) ; loadedPlugins [ pluginNameWithoutPrefix ] = plugin ; } catch ( err ) { plugin = { rulesConfig : { } } ; } } else { plugin = loadedPlugins [ pluginNameWithoutPrefix ] ; } if ( ! plugin . rulesConfig ) { plugin . rulesConfig = { } ; } Object . keys ( plugin . rulesConfig ) . forEach ( function ( item ) { rules [ pluginNameWithoutPrefix + '/' + item ] = plugin . rulesConfig [ item ] ; } ) ; pluginConfig = util . mergeConfigs ( pluginConfig , rules ) ; } ) ; return { rules : pluginConfig } ; }
Load configuration for all plugins provided.
@param {string[]} pluginNames An array of plugin names which should be loaded.
@returns {Object} all plugin configurations merged together
Load configuration for all plugins provided .