mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-20 01:47:35 +00:00
feature(config) tryrequire -> try-catch
This commit is contained in:
parent
2e6474cf8f
commit
100edf8b41
2 changed files with 16 additions and 3 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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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": {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue