lib/config.js
function getLocalConfig(thisConfig, directory) {
  var found,
    i,
    localConfig,
    localConfigFile,
    config = {},
    localConfigFiles = thisConfig.findLocalConfigFiles(directory),
    numFiles = localConfigFiles.length,
    rootPath,
    projectConfigPath = path.join(process.cwd(), LOCAL_CONFIG_FILENAME);

  for (i = 0; i < numFiles; i++) {

    localConfigFile = localConfigFiles[i];

        // Don't consider the personal config file in the home directory,
        // except if the home directory is the same as the current working directory
    if (localConfigFile === PERSONAL_CONFIG_PATH && localConfigFile !== projectConfigPath) {
      continue;
    }

        // If root flag is set, don't consider file if it is above root
    if (rootPath && !pathIsInside(path.dirname(localConfigFile), rootPath)) {
      continue;
    }

    localConfig = loadConfig(localConfigFile);

        // Don't consider a local config file found if the config is empty.
    if (!Object.keys(localConfig).length) {
      continue;
    }

        // Check for root flag
    if (localConfig.root === true) {
      rootPath = path.dirname(localConfigFile);
    }

    found = true;
    config = util.mergeConfigs(localConfig, config);
  }

    // Use the personal config file if there are no other local config files found.
  return found ? config : util.mergeConfigs(config, getPersonalConfig());
}
function getLocalConfig(thisConfig, directory) {
  var found,
    i,
    localConfig,
    localConfigFile,
    config = {},
    localConfigFiles = thisConfig.findLocalConfigFiles(directory),
    numFiles = localConfigFiles.length,
    rootPath,
    projectConfigPath = path.join(process.cwd(), LOCAL_CONFIG_FILENAME);

  for (i = 0; i < numFiles; i++) {

    localConfigFile = localConfigFiles[i];

        // Don't consider the personal config file in the home directory,
        // except if the home directory is the same as the current working directory
    if (localConfigFile === PERSONAL_CONFIG_PATH && localConfigFile !== projectConfigPath) {
      continue;
    }

        // If root flag is set, don't consider file if it is above root
    if (rootPath && !pathIsInside(path.dirname(localConfigFile), rootPath)) {
      continue;
    }

    localConfig = loadConfig(localConfigFile);

        // Don't consider a local config file found if the config is empty.
    if (!Object.keys(localConfig).length) {
      continue;
    }

        // Check for root flag
    if (localConfig.root === true) {
      rootPath = path.dirname(localConfigFile);
    }

    found = true;
    config = util.mergeConfigs(localConfig, config);
  }

    // Use the personal config file if there are no other local config files found.
  return found ? config : util.mergeConfigs(config, getPersonalConfig());
}
function getLocalConfig ( thisConfig , directory ) { var found , i , localConfig , localConfigFile , config = { } , localConfigFiles = thisConfig . findLocalConfigFiles ( directory ) , numFiles = localConfigFiles . length , rootPath , projectConfigPath = path . join ( process . cwd ( ) , LOCAL_CONFIG_FILENAME ) ; for ( i = 0 ; i < numFiles ; i ++ ) { localConfigFile = localConfigFiles [ i ] ; // Don't consider the personal config file in the home directory, // except if the home directory is the same as the current working directory if ( localConfigFile === PERSONAL_CONFIG_PATH && localConfigFile !== projectConfigPath ) { continue ; } // If root flag is set, don't consider file if it is above root if ( rootPath && ! pathIsInside ( path . dirname ( localConfigFile ) , rootPath ) ) { continue ; } localConfig = loadConfig ( localConfigFile ) ; // Don't consider a local config file found if the config is empty. if ( ! Object . keys ( localConfig ) . length ) { continue ; } // Check for root flag if ( localConfig . root === true ) { rootPath = path . dirname ( localConfigFile ) ; } found = true ; config = util . mergeConfigs ( localConfig , config ) ; } // Use the personal config file if there are no other local config files found. return found ? config : util . mergeConfigs ( config , getPersonalConfig ( ) ) ; }
Get a local config object.
@param {Object} thisConfig A Config object.
@param {string} directory The directory to start looking in for a local config file.
@returns {Object} The local config object, or an empty object if there is no local config.
Get a local config object .