lib/config/config.js
function loadConfig(dir, name, warn, defaultEmpty, isEnvironment) {
	var extensionlessSource = path.join(dir, name);
	var rawSource;
	var rawConfig;

	for (var i = 0; i < supportedTypes.length && !rawConfig; i++) {
		rawSource = extensionlessSource + supportedTypes[i];

		if (fs.existsSync(rawSource)) {
			rawConfig = loadConfigFile(rawSource);
		}
	}

	if (!rawConfig) {
		if (warn) {
			logger.info(
				'No configuration content of name "' + name + '" was loaded from directory:',
				configDir
			);
		}

		if (!defaultEmpty) {
			return;
		}

		rawSource = module.filename;
		rawConfig = {};
	}

	if (rawConfig && isEnvironment) {
		rawConfig = loadEnvironment(rawConfig);
	}

	return { source: rawSource, config: rawConfig };
}
function loadConfig(dir, name, warn, defaultEmpty, isEnvironment) {
	var extensionlessSource = path.join(dir, name);
	var rawSource;
	var rawConfig;

	for (var i = 0; i < supportedTypes.length && !rawConfig; i++) {
		rawSource = extensionlessSource + supportedTypes[i];

		if (fs.existsSync(rawSource)) {
			rawConfig = loadConfigFile(rawSource);
		}
	}

	if (!rawConfig) {
		if (warn) {
			logger.info(
				'No configuration content of name "' + name + '" was loaded from directory:',
				configDir
			);
		}

		if (!defaultEmpty) {
			return;
		}

		rawSource = module.filename;
		rawConfig = {};
	}

	if (rawConfig && isEnvironment) {
		rawConfig = loadEnvironment(rawConfig);
	}

	return { source: rawSource, config: rawConfig };
}
function loadConfig ( dir , name , warn , defaultEmpty , isEnvironment ) { var extensionlessSource = path . join ( dir , name ) ; var rawSource ; var rawConfig ; for ( var i = 0 ; i < supportedTypes . length && ! rawConfig ; i ++ ) { rawSource = extensionlessSource + supportedTypes [ i ] ; if ( fs . existsSync ( rawSource ) ) { rawConfig = loadConfigFile ( rawSource ) ; } } if ( ! rawConfig ) { if ( warn ) { logger . info ( 'No configuration content of name "' + name + '" was loaded from directory:' , configDir ) ; } if ( ! defaultEmpty ) { return ; } rawSource = module . filename ; rawConfig = { } ; } if ( rawConfig && isEnvironment ) { rawConfig = loadEnvironment ( rawConfig ) ; } return { source : rawSource , config : rawConfig } ; }
Given a file name without extension, attempt to load the file. The files are assumed to be in a
folder called 'config' that lives in the same directory that you booted your game in.

@param  {String}  dir           An absolute path to the directory containing the config file.
@param  {String}  name          The file name (without extension).
@param  {Boolean} warn          Warn if configuration file was not found.
@param  {Boolean} defaultEmpty  Set to true to return undefined rather than a fresh empty config.
@param  {Boolean} isEnvironment Set to true if the file describe environment variables
@return {Object}                Contains "source" (the complete file path) and "config" keys.
Given a file name without extension attempt to load the file . The files are assumed to be in a folder called config that lives in the same directory that you booted your game in .