fabric-client/lib/Client.js
function _getNetworkConfig(loadConfig, client) {
	let network_config = null;
	let network_data = null;
	let network_config_loc = null;
	if (typeof loadConfig === 'string') {
		network_config_loc = path.resolve(loadConfig);
		logger.debug('%s - looking at absolute path of ==>%s<==', '_getNetworkConfig', network_config_loc);
		const file_data = fs.readFileSync(network_config_loc);
		const file_ext = path.extname(network_config_loc);
		// maybe the file is yaml else has to be JSON
		if ((/(yml|yaml)$/i).test(file_ext)) {
			network_data = yaml.safeLoad(file_data);
		} else {
			network_data = JSON.parse(file_data);
		}
	} else {
		network_data = loadConfig;
	}

	try {
		if (!network_data) {
			throw new Error('missing configuration data');
		}
		if (!network_data.version) {
			throw new Error('"version" is missing');
		}
		const parsing = Client.getConfigSetting('network-config-schema');
		if (!parsing) {
			throw new Error('missing "network-config-schema" configuration setting');
		}
		const pieces = network_data.version.toString().split('.');
		const version = pieces[0] + '.' + pieces[1];
		if (!parsing[version]) {
			throw new Error('common connection profile has an unknown "version"');
		}
		const NetworkConfig = require(parsing[version]);
		network_config = new NetworkConfig(network_data, client, network_config_loc);
	} catch (error) {
		throw new Error(util.format('Invalid common connection profile due to %s', error.message));
	}

	return network_config;
}
function _getNetworkConfig(loadConfig, client) {
	let network_config = null;
	let network_data = null;
	let network_config_loc = null;
	if (typeof loadConfig === 'string') {
		network_config_loc = path.resolve(loadConfig);
		logger.debug('%s - looking at absolute path of ==>%s<==', '_getNetworkConfig', network_config_loc);
		const file_data = fs.readFileSync(network_config_loc);
		const file_ext = path.extname(network_config_loc);
		// maybe the file is yaml else has to be JSON
		if ((/(yml|yaml)$/i).test(file_ext)) {
			network_data = yaml.safeLoad(file_data);
		} else {
			network_data = JSON.parse(file_data);
		}
	} else {
		network_data = loadConfig;
	}

	try {
		if (!network_data) {
			throw new Error('missing configuration data');
		}
		if (!network_data.version) {
			throw new Error('"version" is missing');
		}
		const parsing = Client.getConfigSetting('network-config-schema');
		if (!parsing) {
			throw new Error('missing "network-config-schema" configuration setting');
		}
		const pieces = network_data.version.toString().split('.');
		const version = pieces[0] + '.' + pieces[1];
		if (!parsing[version]) {
			throw new Error('common connection profile has an unknown "version"');
		}
		const NetworkConfig = require(parsing[version]);
		network_config = new NetworkConfig(network_data, client, network_config_loc);
	} catch (error) {
		throw new Error(util.format('Invalid common connection profile due to %s', error.message));
	}

	return network_config;
}
function _getNetworkConfig ( loadConfig , client ) { let network_config = null ; let network_data = null ; let network_config_loc = null ; if ( typeof loadConfig === 'string' ) { network_config_loc = path . resolve ( loadConfig ) ; logger . debug ( '%s - looking at absolute path of ==>%s<==' , '_getNetworkConfig' , network_config_loc ) ; const file_data = fs . readFileSync ( network_config_loc ) ; const file_ext = path . extname ( network_config_loc ) ; // maybe the file is yaml else has to be JSON if ( ( / (yml|yaml)$ / i ) . test ( file_ext ) ) { network_data = yaml . safeLoad ( file_data ) ; } else { network_data = JSON . parse ( file_data ) ; } } else { network_data = loadConfig ; } try { if ( ! network_data ) { throw new Error ( 'missing configuration data' ) ; } if ( ! network_data . version ) { throw new Error ( '"version" is missing' ) ; } const parsing = Client . getConfigSetting ( 'network-config-schema' ) ; if ( ! parsing ) { throw new Error ( 'missing "network-config-schema" configuration setting' ) ; } const pieces = network_data . version . toString ( ) . split ( '.' ) ; const version = pieces [ 0 ] + '.' + pieces [ 1 ] ; if ( ! parsing [ version ] ) { throw new Error ( 'common connection profile has an unknown "version"' ) ; } const NetworkConfig = require ( parsing [ version ] ) ; network_config = new NetworkConfig ( network_data , client , network_config_loc ) ; } catch ( error ) { throw new Error ( util . format ( 'Invalid common connection profile due to %s' , error . message ) ) ; } return network_config ; }
internal utility method to get a NetworkConfig
internal utility method to get a NetworkConfig