From bd1ecc950e644341445cce03e758b1ed0a06e6ba Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 10 Feb 2014 03:56:56 -0500 Subject: [PATCH] refactor(cloudcmd) readConfig: add encoding --- cloudcmd.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/cloudcmd.js b/cloudcmd.js index aa0c9e0e..a703abba 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -181,16 +181,15 @@ }); } - function readConfig(pCallBack) { - fs.readFile(CONFIG_PATH, function(pError, pData) { - var msg, status, str, readed; + function readConfig(callback) { + fs.readFile(CONFIG_PATH, 'utf8', function(error, data) { + var msg, status, readed; - if (pError) + if (error) status = 'error'; else { status = 'ok'; - str = pData.toString(), - readed = Util.parseJSON(str); + readed = Util.parseJSON(data); main.config = Config = readed; } @@ -198,7 +197,7 @@ msg = CloudFunc.formatMsg('read', 'config', status); Util.log(msg); - Util.exec(pCallBack); + Util.exec(callback); }); }