Comparing version 1.0.1 to 1.0.2
42
index.js
@@ -36,2 +36,24 @@ /** | ||
del.count = function(files) { | ||
var c = { | ||
fileCount: 0, | ||
dirCount: 0, | ||
totalSize: 0 | ||
}; | ||
if (!files) { | ||
return c; | ||
} | ||
if (!util.isArray(files)) { | ||
files = [files]; | ||
} | ||
files.forEach(function(f) { | ||
_count(f, c); | ||
}); | ||
return c; | ||
}; | ||
module.exports = del; | ||
@@ -58,1 +80,21 @@ | ||
} | ||
function _count(f, c) { | ||
if (!fs.existsSync(f)) { | ||
return; | ||
} | ||
var stat = fs.statSync(f); | ||
if (stat.isDirectory()) { | ||
c.dirCount ++; | ||
var subs = fs.readdirSync(f) || []; | ||
subs.forEach(function(sub) { | ||
_count(path.join(f, sub), c); | ||
}); | ||
} else if (stat.isFile()) { | ||
c.fileCount ++; | ||
c.totalSize += stat.size; | ||
} | ||
} |
{ | ||
"name": "fs-del", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "delete files and folders", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -17,5 +17,10 @@ /** | ||
it.only('empty', function() { | ||
it('empty', function() { | ||
del.empty('E:/test/s3') | ||
}) | ||
}); | ||
it.only('count', function() { | ||
var c = del.count('E:/test'); | ||
console.log(c); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2957
101