feature(config) tryrequire -> try-catch

This commit is contained in:
coderaiser 2015-04-07 06:26:17 -04:00
parent 2e6474cf8f
commit 100edf8b41
2 changed files with 16 additions and 3 deletions

View file

@ -17,7 +17,7 @@
CloudFunc = require(DIR_LIB + 'cloudfunc'),
check = require('checkup'),
tryRequire = require('tryrequire'),
tryCatch = require('try-catch'),
pipe = require('pipe-io'),
ponse = require('ponse'),
json = require('jonny'),
@ -29,12 +29,24 @@
config =
tryRequire(ConfigHome) ||
tryRequire(ConfigPath, {log: true}) || {};
tryRequire(ConfigPath);
module.exports = manage;
module.exports.save = save;
module.exports.socket = socket;
function tryRequire(path) {
var ret,
error = tryCatch(function() {
ret = require(path);
});
if (error && error.code !== 'MODULE_NOT_FOUND')
console.error(error.message);
return ret;
}
function manage(key, value) {
var result;

View file

@ -55,6 +55,7 @@
"rendy": "~1.0.2",
"restafary": "~1.1.0",
"socket.io": "~1.3.5",
"try-catch": "~1.0.0",
"tryrequire": "~1.1.5"
},
"devDependencies": {