mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature(cloudcmd) start: add ability to override default config
This commit is contained in:
parent
8cbbc52a74
commit
1f4cabf15e
2 changed files with 41 additions and 31 deletions
|
|
@ -47,35 +47,7 @@
|
|||
function start(params) {
|
||||
var cloudcmd = require('../cloudcmd');
|
||||
|
||||
readConfig(function(msg, config) {
|
||||
if (params && params.test)
|
||||
config.test = params.test;
|
||||
|
||||
Util.log(msg);
|
||||
|
||||
cloudcmd.start(config);
|
||||
});
|
||||
}
|
||||
|
||||
function readConfig(callback) {
|
||||
var path = DIR + 'json/config.json';
|
||||
|
||||
Util.checkArgs(arguments, ['callback']);
|
||||
|
||||
fs.readFile(path, 'utf8', function(error, data) {
|
||||
var status, config, msg;
|
||||
|
||||
if (error) {
|
||||
status = 'error';
|
||||
} else {
|
||||
status = 'ok';
|
||||
config = Util.parseJSON(data);
|
||||
}
|
||||
|
||||
msg = CloudFunc.formatMsg('read', 'config', status);
|
||||
|
||||
callback(msg, config);
|
||||
});
|
||||
cloudcmd.start(params);
|
||||
}
|
||||
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue