feature(config) tryrequire -> try-catch

This commit is contained in:
coderaiser 2015-04-07 06:26:17 -04:00
parent 29beabb114
commit 99d55be497
3 changed files with 21 additions and 4 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

@ -4,7 +4,8 @@
var DIR = './',
path = require('path'),
config = require(DIR + 'config'),
mellow = require('mellow');
mellow = require('mellow'),
log = require('debug')('cloudcmd-root');
module.exports = function(dir) {
var root = config('root') || '/';
@ -14,6 +15,8 @@
else
dir = path.join(root + dir);
log(dir);
return dir;
};
})();

View file

@ -33,6 +33,7 @@
"checkup": "~1.0.3",
"console-io": "~2.2.0",
"copymitter": "~1.6.0",
"debug": "~2.1.3",
"dword": "~1.3.2",
"edward": "~1.4.0",
"execon": "~1.1.0",
@ -55,6 +56,7 @@
"rendy": "~1.0.2",
"restafary": "~1.2.0",
"socket.io": "~1.3.5",
"try-catch": "~1.0.0",
"tryrequire": "~1.1.5"
},
"devDependencies": {