refactor(commander) readDir

This commit is contained in:
coderaiser 2014-07-04 07:38:25 -04:00
parent 3e1dc7c582
commit 901f63a866

View file

@ -40,7 +40,7 @@
* @param pFiles
*/
function readDir(params, error, files) {
var i, n, stats, filesData, fill, name, fileParams,
var n, stats, filesData, fill, fileParams,
p = params,
dirPath = format.addSlashToEnd(p.path);
@ -60,21 +60,19 @@
fill = fillJSON.bind(null, filesData);
if (n)
for (i = 0; i < n; i++) {
name = dirPath + files[i],
if (!n)
fillJSON(filesData);
else
files.forEach(function(name) {
fileParams = {
callback : fill,
count : n,
name : files[i],
name : name,
stats : stats,
};
fs.lstat(name, onStat.bind(null, fileParams));
}
else
fillJSON(filesData);
fs.lstat(dirPath + name, onStat.bind(null, fileParams));
});
}
}