mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-19 09:24:51 +00:00
chore(commander) add " "
This commit is contained in:
parent
402696deec
commit
8036e3be65
1 changed files with 23 additions and 24 deletions
|
|
@ -1,7 +1,7 @@
|
|||
(function(){
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
if(!global.cloudcmd)
|
||||
if (!global.cloudcmd)
|
||||
return console.log(
|
||||
'# commander.js' + '\n' +
|
||||
'# -----------' + '\n' +
|
||||
|
|
@ -14,9 +14,10 @@
|
|||
fs = main.fs,
|
||||
Util = main.util;
|
||||
|
||||
exports.getDirContent = function(pPath, pCallBack){
|
||||
exports.getDirContent = function(pPath, pCallBack) {
|
||||
var lRet = Util.isString(pPath);
|
||||
if( lRet )
|
||||
|
||||
if (lRet)
|
||||
fs.readdir(pPath, Util.call(readDir, {
|
||||
callback: pCallBack,
|
||||
path : pPath
|
||||
|
|
@ -33,16 +34,17 @@
|
|||
* @param pError
|
||||
* @param pFiles
|
||||
*/
|
||||
function readDir(pParams){
|
||||
function readDir(pParams) {
|
||||
var lRet = checkParams(pParams);
|
||||
lRet = lRet && Util.checkObj(pParams.params, ['path']);
|
||||
if(lRet){
|
||||
|
||||
if (lRet) {
|
||||
var p = pParams,
|
||||
c = pParams.params,
|
||||
lFiles = p.data,
|
||||
lDirPath = getDirPath(c.path);
|
||||
|
||||
if(!p.error && lFiles){
|
||||
if (!p.error && lFiles) {
|
||||
lFiles.data = lFiles.sort();
|
||||
|
||||
/* Получаем информацию о файлах */
|
||||
|
|
@ -59,8 +61,8 @@
|
|||
fillJSON(lFilesData);
|
||||
};
|
||||
|
||||
if(n){
|
||||
for(var i = 0; i < n; i++){
|
||||
if (n)
|
||||
for (var i = 0; i < n; i++) {
|
||||
var lName = lDirPath + lFiles[i],
|
||||
lParams = {
|
||||
callback : lFill,
|
||||
|
|
@ -69,13 +71,11 @@
|
|||
stats : lStats,
|
||||
};
|
||||
|
||||
fs.stat( lName, Util.call(getFilesStat, lParams) );
|
||||
fs.stat(lName, Util.call(getFilesStat, lParams));
|
||||
}
|
||||
}
|
||||
else
|
||||
fillJSON(lFilesData);
|
||||
}
|
||||
else
|
||||
} else
|
||||
Util.exec(c.callback, p.error.toString());
|
||||
}
|
||||
}
|
||||
|
|
@ -84,12 +84,12 @@
|
|||
* async getting file states
|
||||
* and putting it to lStats object
|
||||
*/
|
||||
function getFilesStat(pParams){
|
||||
function getFilesStat(pParams) {
|
||||
var lRet = checkParams(pParams);
|
||||
lRet = lRet && Util.checkObjTrue(pParams.params,
|
||||
['callback', 'stats', 'name', 'count']);
|
||||
|
||||
if(lRet){
|
||||
if (lRet) {
|
||||
var p = pParams,
|
||||
c = p.params;
|
||||
|
||||
|
|
@ -99,7 +99,7 @@
|
|||
'isDirectory' : Util.retFalse
|
||||
};
|
||||
|
||||
if(c.count === Object.keys(c.stats).length)
|
||||
if (c.count === Object.keys(c.stats).length)
|
||||
Util.exec(c.callback);
|
||||
}
|
||||
}
|
||||
|
|
@ -112,11 +112,10 @@
|
|||
*
|
||||
* @param pFiles - array of files of current directory
|
||||
*/
|
||||
function fillJSON(pParams){
|
||||
function fillJSON(pParams) {
|
||||
var lRet = Util.checkObjTrue(pParams, ['files', 'stats', 'path']);
|
||||
|
||||
if(lRet)
|
||||
{
|
||||
if (lRet) {
|
||||
var p = pParams,
|
||||
i, n = p.files.length || 0,
|
||||
|
||||
|
|
@ -131,12 +130,12 @@
|
|||
};
|
||||
|
||||
var lName, lStats, lMode, lIsDir;
|
||||
for( i = 0; i < n; i++ ){
|
||||
for (i = 0; i < n; i++ ) {
|
||||
/* Переводим права доступа в 8-ричную систему */
|
||||
lName = p.files[i],
|
||||
lStats = p.stats[lName];
|
||||
|
||||
if(lStats){
|
||||
if (lStats) {
|
||||
lMode = (lStats.mode - 0).toString(8),
|
||||
lIsDir = lStats.isDirectory();
|
||||
}
|
||||
|
|
@ -158,14 +157,14 @@
|
|||
}
|
||||
}
|
||||
|
||||
function checkParams(pParams){
|
||||
function checkParams(pParams) {
|
||||
return Util.checkObj(pParams, ['error', 'data', 'params']);
|
||||
}
|
||||
|
||||
function getDirPath(pPath){
|
||||
function getDirPath(pPath) {
|
||||
var lRet = pPath;
|
||||
|
||||
if(lRet !== '/')
|
||||
if (lRet !== '/')
|
||||
lRet += '/';
|
||||
|
||||
return lRet;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue