flosse / sloc

simple tool to count SLOC (source lines of code)
MIT License
945 stars 83 forks source link

Fails on empty directory #15

Closed aglitchman closed 10 years ago

aglitchman commented 10 years ago

node v0.10.29, OS X

Test:

mkdir empty
sloc empty/

Result:

/xxx/sloc/lib/helpers.js:32
    return fileStats.reduce(function(a, b) {
                     ^
TypeError: Reduce of empty array with no initial value
    at Array.reduce (native)
    at Object.summarize (/xxx/sloc/lib/helpers.js:32:22)
    at finish (/xxx/sloc/lib/cli.js:147:32)
    at Object.async.each (/xxx/sloc/node_modules/async/lib/async.js:121:20)
    at /xxx/sloc/lib/cli.js:162:20
    at /xxx/sloc/node_modules/readdirp/readdirp.js:276:9
    at /xxx/sloc/node_modules/readdirp/readdirp.js:236:11
    at /xxx/sloc/node_modules/readdirp/readdirp.js:171:9
    at LOOP (fs.js:1363:14)
    at process._tickCallback (node.js:419:13)
flosse commented 10 years ago

Uhh...damn! That's definitely a bug :( Thx for that feedback!

flosse commented 10 years ago

should be fixed now :)