Files
deployd/lib/config.js
2011-11-10 20:03:49 -08:00

21 lines
505 B
JavaScript

var CONFIG_PATH = './config/'
, fs = require('fs')
, cache = {};
exports.load = function(path) {
var data = fs.readFileSync(CONFIG_PATH + (path || (path = 'app.json')))
, json = cache[path] || (cache[path] = JSON.parse(data))
, bootedWith = process.argv[2]
, bootedJSON = bootedWith && JSON.parse(bootedWith)
;
if(bootedJSON) {
for(var key in bootedJSON) {
if(bootedJSON.hasOwnProperty(key)) {
json[key] = bootedJSON[key];
}
}
}
return json;
};