diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js index 794d4e2c..c749a047 100644 --- a/lib/cloudfunc.js +++ b/lib/cloudfunc.js @@ -90,6 +90,31 @@ var Util; } }; + /** + * ad new line (if it's not) + * @param {string} pText + */ + this.addNewLine = function(text) { + var newLine = '', + n = text && text.length; + + if(n && text[n-1] !== '\n') + newLine = '\n'; + + return text + newLine; + }; + + /** + * rm new line (if it's) + * @param {string} pText + */ + this.rmNewLine = function(text) { + var strs = ['\n', '\r'], + str = Util.removeStr(text, strs); + + return str; + }; + this.getJoinURL = function(names) { var url, isContain, regExp = new RegExp(',', 'g'), diff --git a/lib/server/console.js b/lib/server/console.js index c465239e..3b5783e4 100644 --- a/lib/server/console.js +++ b/lib/server/console.js @@ -168,7 +168,7 @@ if (firstChar === '#') { pCommand = pCommand.slice(1); pCommand = connName + pCommand; - pCommand = Util.addNewLine(pCommand); + pCommand = CloudFunc.addNewLine(pCommand); Util.exec(callback, { stdout: pCommand @@ -197,7 +197,7 @@ else lErrorStr = lError.toString(); - lErrorStr = Util.addNewLine(lErrorStr); + lErrorStr = CloudFunc.addNewLine(lErrorStr); } lExec = { @@ -263,7 +263,7 @@ update.get(); Util.exec(callback, { - stdout: Util.addNewLine('update: ok') + stdout: CloudFunc.addNewLine('update: ok') }); } @@ -296,7 +296,7 @@ Util.exec(callback, { stderr : lMsg, - stdout : Util.rmNewLine(stdout) + stdout : CloudFunc.rmNewLine(stdout) }); }); } diff --git a/lib/util.js b/lib/util.js index c1d0dce0..017d3a31 100644 --- a/lib/util.js +++ b/lib/util.js @@ -70,31 +70,6 @@ return result; }; - /** - * ad new line (if it's not) - * @param {string} pText - */ - this.addNewLine = function(text) { - var newLine = '', - n = text && text.length; - - if(n && text[n-1] !== '\n') - newLine = '\n'; - - return text + newLine; - }; - - /** - * rm new line (if it's) - * @param {string} pText - */ - this.rmNewLine = function(text) { - var strs = ['\n', '\r'], - str = Util.removeStr(text, strs); - - return str; - }; - /** * Функция ищет в имени файла расширение * и если находит возвращает true