Read config files from directory recursively.

@param {string} configDirectory
@param {string} resourceName
@param {object} resources
@return {Array}
@private
425524
function walk(configDirectory, resourceName, resources) {
    resourceName = resourceName || '';
    resources = resources || {};

    fs.readdirSync(path.join(configDirectory, resourceName)).forEach(fileName => {
        const subResourceName = (resourceName !== '' ? resourceName + '/' : '') + fileName;
        const absoluteFilePath = path.join(configDirectory, subResourceName);
        const stat = fs.statSync(absoluteFilePath);
        if (stat && stat.isDirectory()) {
            walk(configDirectory, subResourceName, resources);
        } else if (resourceName !== '') {
            if (fileName.startsWith('config.')) {
                if (!resources[resourceName]) resources[resourceName] = {};
                resources[resourceName].configFile = absoluteFilePath;
            }
            if (fileName === 'index.js') {
                if (!resources[resourceName]) resources[resourceName] = {};
                resources[resourceName].instanceFile = absoluteFilePath;
            }
        }
    });

    return resources;
}
986124
function loadResources( state, filePath ) {
	var resourcePath = path.resolve( process.cwd(), filePath );
	return getResources( resourcePath )
		.then( function( list ) {
			return when.all( _.map( _.filter( list ), loadModule.bind( undefined, state ) ) )
				.then( function( lists ) {
					return _.flatten( lists );
				} );
		} );
}
449745
function (rootdir, platform, preferenceMappingData) {
        var configData = {};
        lib.parsePreferences(rootdir, configData, platform, preferenceMappingData);
        lib.parseConfigFiles(rootdir, configData, platform);
        return configData;
    }
114991
private void readConfigFile() {

        m_isValid = false;
        if ((null != m_configFile) && m_configFile.exists()) {
            if (m_configFile.canRead()) {
                Properties props = new Properties();
                try (FileInputStream input = new FileInputStream(m_configFile)) {
                    props.load(input);
                    for (Entry<Object, Object> entry : props.entrySet()) {
                        String key = (String)entry.getKey();
                        String propValue = (String)entry.getValue();
                        if (key.equals(DEFAULT_MODULES_TO_EXPORT)) {
                            String value = getValueFromProp(propValue).trim();
                            if (value.contains(",")) {
                                m_configuredModules = Arrays.asList(value.split(" *, *"));
                            } else {
                                m_configuredModules = Arrays.asList(value.split(" +"));
                            }
                        }

                        if (key.equals(DEFAULT_MODULE_PATH)) {
                            m_modulesPath = getValueFromProp(propValue).trim();
                        }

                        if (key.equals(DEFAULT_MODULE_RESOURCES_SUBFOLDER)) {
                            m_resourcesSubfolder = getValueFromProp(propValue).trim();
                        }

                        if (key.equals(DEFAULT_PULL_MODE_BEFORE)) {
                            String value = getValueFromProp(propValue);
                            value = value.trim();
                            if (value.equals("1")) {
                                m_defaultPullModeBefore = true;
                            }
                        }
                        if (key.equals(DEFAULT_PULL_MODE_AFTER)) {
                            String value = getValueFromProp(propValue);
                            value = value.trim();
                            if (value.equals("1")) {
                                m_defaultPullModeAfter = true;
                            }
                        }
                        if (key.equals(DEFAULT_PUSH_MODE)) {
                            String value = getValueFromProp(propValue);
                            value = value.trim();
                            if (value.equals("1")) {
                                m_defaultPushMode = true;
                            }
                        }
                        if (key.equals(DEFAULT_MODULE_EXPORT_PATH)) {
                            String value = getValueFromProp(propValue);
                            m_defaultModuleExportPath = value.trim();
                        }
                        if (key.equals(DEFAULT_REPOSITORY_PATH)) {
                            String value = getValueFromProp(propValue);
                            m_repositoryPath = value.trim();
                        }
                        if (key.equals(DEFAULT_EXPORT_MODE)) {
                            String value = getValueFromProp(propValue);
                            m_defaultExportMode = (value.trim().equals("1")) ? 1 : 0;
                        }
                        if (key.equals(DEFAULT_COMMIT_MESSAGE)) {
                            String value = getValueFromProp(propValue);
                            m_defaultCommitMessage = value;
                        }
                        if (key.equals(DEFAULT_GIT_USER_NAME)) {
                            String value = getValueFromProp(propValue);
                            m_defaultGitUserName = value;
                        }
                        if (key.equals(DEFAULT_GIT_USER_EMAIL)) {
                            String value = getValueFromProp(propValue);
                            m_defaultGitUserEmail = value;
                        }
                        if (key.equals(DEFAULT_EXCLUDE_LIBS)) {
                            String value = getValueFromProp(propValue);
                            m_defaultExcludeLibs = (value.trim().equals("1")) ? true : false;
                        }
                        if (key.equals(DEFAULT_COMMIT_MODE)) {
                            String value = getValueFromProp(propValue);
                            m_defaultCommitMode = (value.trim().equals("1")) ? true : false;
                        }
                        if (key.equals(DEFAULT_IGNORE_UNCLEAN)) {
                            String value = getValueFromProp(propValue);
                            m_defaultIgnoreUnclean = (value.trim().equals("1")) ? true : false;
                        }
                        if (key.equals(DEFAULT_COPY_AND_UNZIP)) {
                            String value = getValueFromProp(propValue);
                            m_defaultCopyAndUnzip = (value.trim().equals("1")) ? true : false;
                        }
                    }
                    m_isValid = true;
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
764491
function readConfig() {
  const patten = `${process.cwd()}/config/*.json`
  return glob.sync(patten).reduce((acc, curr) => {
    var ctx = !env ? require(curr) : require(curr)[env]
    return Object.assign({}, acc, ctx)
  }, {})
}
625730
private Config findAndLoadGlobalConfigInDirectory(Path path, Config fallback) throws IOException {
    FileStatus[] files = this.fs.listStatus(path, GLOBAL_PATH_FILTER);
    if (files == null) {
      log.warn("Could not list files at path " + path);
      return ConfigFactory.empty();
    }
    if (files.length > 1) {
      throw new IOException("Found more than one global properties file at path " + path);
    }
    if (files.length == 0) {
      return fallback;
    }
    if (GLOBAL_HOCON_PATH_FILTER.accept(files[0].getPath())) {
      return loadHoconConfigWithFallback(files[0].getPath(), fallback);
    } else if (GLOBAL_PROPS_PATH_FILTER.accept(files[0].getPath())) {
      return loadJavaPropsWithFallback(files[0].getPath(), fallback);
    } else {
      throw new IllegalStateException("Unsupported global configuration file: " + files[0].getPath());
    }
  }
38029
function useDefaultConfig(){
	logger.info(process.cwd());
	if(fileutil.isExist(path.join(process.cwd() , "/config.json"))){
		var jsonconfig = require(path.join(process.cwd() ,'/config.json'));
		buildFromJsonConfig(jsonconfig);
	}else{
		logger.warn("config.json is not found. Checking for directory structure");
		buildFromDirectory(process.cwd());
	}
}
595876
function loadConfig(path) {
    var glob = require('glob');
    var object = {};
    var key;

    glob.sync('*', {cwd: path}).forEach(function(option) {
      key = option.replace(/\.js$/,'');
      object[key] = require(path + option);
    });

    return object;
  }
946949
private File getFileFromConfigDirectory(String file, File def) {
        File f = new File(configDirectory, file);
        if (configDirectory != null && f.exists()) {
            return f;
        }
        if (def != null && def.exists()) {
            return def;
        }
        return null;
    }
136148
function readConfigFile(configJSONPath) {
  var confiJSONFullPath = path.join(process.cwd(), configJSONPath);
  
  try{
    var configStr = fs.readFileSync(confiJSONFullPath, {encoding:'utf8'});
    return JSON.parse(configStr);
  } catch (err){
    throw new Error(`Invalid launcher configuration file: ${confiJSONFullPath}
${err.toString()}`);
  }
}
452304
function initServicesDir (config, dir) {
    // iterate over file names in directory
    _.each(fs.readdirSync(dir), file => {
        // get absolute file
        var absFile = `${dir}/${file}`
        // match services files
        var matches = file.match(/^(.*?)\.service\.js$/)
        // load file if it matches filename pattern
        if (matches) {
            // get service name from file name
            var serviceName = changeCase.camelCase(matches[1])
            // load service
            var service = require(path.relative(__dirname, absFile))
            // validate service name if defined
            if (defined(service.name)) {
                assert(service.name === serviceName, `service name ${service.name} does not match filename ${absFile}`)
            }
            // otherwise set service name from file name
            else {
                service.name = serviceName
            }
            // if service is already defined merge over existing definition
            if (defined(config.services[service.name])) {
                _.merge(config.services[service.name], service)
            }
            // otherwise set new service
            else {
                config.services[service.name] = service
            }
        }
        // ignore anything else
        else {
            debug('initServicesDir: ignoring %s', absFile)
        }
    })
}
1168895
function loadConfig() {
  var root = process.cwd()
    , config = readConfig(path.join(root, '_config.json'));
  config.root = root;
  return config;
}
1337712
function findConfigFiles (dir) {
  let result = []

  if (typeof dir !== 'string' || !fs.existsSync(dir)) {
    return result
  }

  const fileList = fs.readdirSync(dir)

  debug(`${dir} file list: %o`, fileList)

  result = linterConfigFile
    .filter(fileName => fileList.includes(fileName))
    .map(fileName => path.join(dir, fileName))

  debug('config file: %o', result)

  return result
}
530993
function configFactory(filename, options) {
    if (!_.isObject(options)) {
        options = {};
    }

    var config = WebpackConfig.loader.loadConfig(filename),
        isArray = _.isArray(config);

    if (!isArray) {
        config = [config];
    }

    config = _.map(config, function(x) {
        x.merge(options);
        x.defaults({
            output: {
                path: path.dirname(filename)
            }
        });

        return x;
    });

    return isArray ? config : _.first(config);
}
1113242
function(config) {
    var directory = null;

    if(config.workingDir) {
       directory = path.join(config.workingDir, 'level'); 
    } else {
        throw Errors.invalidConfig('Invalid configuration. Working directory not defined.');
    }
    
    return directory;
}
903114
@Override
  public void parseDirectory(File configurationDirectory) throws Exception {
    this.configurationDirectory = configurationDirectory;
    if(configurationDirectory != null && configurationDirectory.isDirectory() && configurationDirectory.canRead()) {
      Collection<File> configFiles = FileUtils.listFiles(configurationDirectory, new String[] {"yml", "yaml"}, true);
      List<File> files = new ArrayList<File>(configFiles);
      Collections.sort(files, NameFileComparator.NAME_INSENSITIVE_COMPARATOR);
      Map<String, Map<String, ?>> configurationMap = new HashMap<String, Map<String, ?>>();
      Yaml yamlParser = new Yaml(getClassTags());
      for(File configFile : files) {
        FileReader reader = null;
        try {
          reader = new FileReader(configFile);
          for(Object parsed : yamlParser.loadAll(reader)){
            mergeConfigs(configurationMap, parsed);
          }
        } finally {
          IOUtils.closeQuietly(reader);
        }
      }
      this.configuration = configurationMap;
    } else if(configurationDirectory != null && configurationDirectory.isDirectory()){
      logger.warn("Directory {} cannot be read.", configurationDirectory);
    } else if(configurationDirectory != null){
      logger.warn("Directory {} is not a directory or does not exist.", configurationDirectory);
    } else {
      throw new IllegalArgumentException("The configurationDirectory must be specified.");
    }
  }
1021941
public void initResourceDir (String resourceDir)
    {
        // if none was specified, check the resource_dir system property
        if (resourceDir == null) {
            try {
                resourceDir = System.getProperty("resource_dir");
            } catch (SecurityException se) {
                // no problem
            }
        }

        // if we found no resource directory, don't use one
        if (resourceDir == null) {
            return;
        }

        // make sure there's a trailing slash
        if (!resourceDir.endsWith(File.separator)) {
            resourceDir += File.separator;
        }
        _rdir = new File(resourceDir);
    }