mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-24 00:21:18 +00:00
refactur(util) mv {add,rm}NewLine to cloudfunc
This commit is contained in:
parent
6653feb6f4
commit
5f92d4208f
3 changed files with 29 additions and 29 deletions
|
|
@ -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'),
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
25
lib/util.js
25
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue