export.js
/**
 * Read configuration file as commandline argument
 */
Read configuration file as commandline argument
Read configuration file as commandline argument
function readConfig() {
	if (process.argv.length <= 2) {
		console.log("Specify path to configuration file(s), for example:");
		console.log("> node export.js hivConfig.json");
		process.exit(1);
	}
	else {
		var thisConf;
		conf = { "export": [] };
		var files = args._;
		for (var i = 0; i < files.length; i++) {
			var fileName = files[i];
			try {
				thisConf = JSON.parse(fs.readFileSync(fileName, "utf8"));
			}
			catch (err) {
				console.log("Problem reading configuration file: " + fileName);
				console.log(err);
				console.log("Please provide a valid path to the configuration file");
				process.exit(1);
			}
			if (!thisConf.hasOwnProperty("export")) {
				console.log("Configuration file " + fileName + " does not have a valid structure");
				process.exit(1);
			}
			conf.export = conf.export.concat(thisConf.export);
			console.log("Loaded configuration file " + fileName);
		}
	}
	return true;
}
function readConfig ( ) { if ( process . argv . length <= 2 ) { console . log ( "Specify path to configuration file(s), for example:" ) ; console . log ( "> node export.js hivConfig.json" ) ; process . exit ( 1 ) ; } else { var thisConf ; conf = { "export" : [ ] } ; var files = args . _ ; for ( var i = 0 ; i < files . length ; i ++ ) { var fileName = files [ i ] ; try { thisConf = JSON . parse ( fs . readFileSync ( fileName , "utf8" ) ) ; } catch ( err ) { console . log ( "Problem reading configuration file: " + fileName ) ; console . log ( err ) ; console . log ( "Please provide a valid path to the configuration file" ) ; process . exit ( 1 ) ; } if ( ! thisConf . hasOwnProperty ( "export" ) ) { console . log ( "Configuration file " + fileName + " does not have a valid structure" ) ; process . exit ( 1 ) ; } conf . export = conf . export . concat ( thisConf . export ) ; console . log ( "Loaded configuration file " + fileName ) ; } } return true ; }
Read configuration file as commandline argument
Read configuration file as commandline argument