From 2c40a543a6fbca4055b4b76ee6cac7b1d7758479 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 11 Jul 2014 02:34:52 -0400 Subject: [PATCH] refactor(cloudcmd) rm IsTest --- bin/cloudcmd.js | 4 ++-- cloudcmd.js | 25 +++++++++++++------------ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/bin/cloudcmd.js b/bin/cloudcmd.js index 2fa0bc4c..efb038a0 100755 --- a/bin/cloudcmd.js +++ b/bin/cloudcmd.js @@ -13,7 +13,7 @@ switch (argvLast) { default: - start({}); + start(); break; case '--test': @@ -21,7 +21,7 @@ Util.log('argv: ', argv); start({ - isTest: true + test: true }); break; diff --git a/cloudcmd.js b/cloudcmd.js index bf6b8855..42d58966 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -42,8 +42,6 @@ 'link', ], - IsTest, - Template = {}, FS = CloudFunc.FS; @@ -51,9 +49,10 @@ DIR = main.DIR; exports.start = function(params) { - IsTest = params.isTest; + readConfig(function() { + init(params); + }); - readConfig(init); win.prepareCodePage(); }; @@ -118,15 +117,15 @@ } - function init() { - var params; + function init(params) { + var paramsStart; + + Util.log('server dir: ' + DIR); if (update) update.get(); - Util.log('server dir: ' + DIR); - - if (IsTest) + if (params && params.test) Config.server = false; if (Config.logs) { @@ -136,13 +135,13 @@ writeLogsToFile(); } - params = { + paramsStart = { appcache : appCacheProcessing, rest : main.rest, route : route }; - readFiles(params, function(params) { + readFiles(paramsStart, function(params) { server.start(params); }); } @@ -194,6 +193,8 @@ } function readConfig(callback) { + Util.checkArgs(arguments, ['callback']); + fs.readFile(CONFIG_PATH, 'utf8', function(error, data) { var status, json, msg; @@ -208,7 +209,7 @@ msg = CloudFunc.formatMsg('read', 'config', status); Util.log(msg); - Util.exec(callback); + callback(); }); }