mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
feature(config) tryrequire -> try-catch
This commit is contained in:
parent
29beabb114
commit
99d55be497
3 changed files with 21 additions and 4 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -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": {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue