const path = require('path'); const fs = require('fs'); const YAML = require('yaml'); var CONFIG = null; var CONFIG_PATH = ""; exports = { get: function(){ if (arguments.length === 1 && typeof(arguments[0]) === 'string'){ if (CONFIG_PATH !== arguments[0]){ var cpath = path.normalize(arguments[0]); if (!path.isAbsolute(cpath)) cpath = path.join(__dirname, cpath); try { CONFIG = YAML.parse(fs.readFileSync(cpath, 'utf8')); } catch (e) { console.log("ERROR: " + e.toString()); } } } return CONFIG; } };