flosse / sloc

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

Can't use --details and --format together #57

Open yaronyg opened 8 years ago

yaronyg commented 8 years ago

Please see example command lines and errors below:

Yarons-MacBook-Pro:Thali_CordovaPlugin yarongoland$ sloc --format cli-table --details test/

/usr/local/lib/node_modules/sloc/node_modules/cli-table/lib/index.js:182
      var contents = item.toString().split("\n").reduce(function (memo, l) {
                          ^
TypeError: Cannot call method 'toString' of undefined
    at /usr/local/lib/node_modules/sloc/node_modules/cli-table/lib/index.js:182:27
    at Array.forEach (native)
    at generateRow (/usr/local/lib/node_modules/sloc/node_modules/cli-table/lib/index.js:181:11)
    at /usr/local/lib/node_modules/sloc/node_modules/cli-table/lib/index.js:275:16
    at Table.forEach (native)
    at Table.toString (/usr/local/lib/node_modules/sloc/node_modules/cli-table/lib/index.js:258:10)
    at module.exports (/usr/local/lib/node_modules/sloc/lib/formatters/cli-table.js:47:18)
    at print (/usr/local/lib/node_modules/sloc/lib/cli.js:98:11)
    at finish (/usr/local/lib/node_modules/sloc/lib/cli.js:170:14)
    at done (/usr/local/lib/node_modules/sloc/node_modules/async/lib/async.js:132:19)
Yarons-MacBook-Pro:Thali_CordovaPlugin yarongoland$ sloc --details --format cli-table  test/

/usr/local/lib/node_modules/sloc/node_modules/cli-table/lib/index.js:182
      var contents = item.toString().split("\n").reduce(function (memo, l) {
                          ^
TypeError: Cannot call method 'toString' of undefined
    at /usr/local/lib/node_modules/sloc/node_modules/cli-table/lib/index.js:182:27
    at Array.forEach (native)
    at generateRow (/usr/local/lib/node_modules/sloc/node_modules/cli-table/lib/index.js:181:11)
    at /usr/local/lib/node_modules/sloc/node_modules/cli-table/lib/index.js:275:16
    at Table.forEach (native)
    at Table.toString (/usr/local/lib/node_modules/sloc/node_modules/cli-table/lib/index.js:258:10)
    at module.exports (/usr/local/lib/node_modules/sloc/lib/formatters/cli-table.js:47:18)
    at print (/usr/local/lib/node_modules/sloc/lib/cli.js:98:11)
    at finish (/usr/local/lib/node_modules/sloc/lib/cli.js:170:14)
    at done (/usr/local/lib/node_modules/sloc/node_modules/async/lib/async.js:132:19)
Yarons-MacBook-Pro:Thali_CordovaPlugin yarongoland$ 

I run the same command twice, I just changed the order of the arguments.

Note, btw, that both sloc --details test/ and sloc --format cli-table test/ work just fine. It's only when I put the two options together that I get the error.

yaronyg commented 8 years ago

I also noticed that SLOC is return things like:

--- node_modules/lie/node_modules/es3ify/node_modules/through/test/buffering.js

               Error :  Bad file

But if I navigate directly down to the through directory and run sloc --details test it runs just fine.

flosse commented 8 years ago

Thanks for reporting! If you like to fix it, go ahead ;-) Otherwise you have to wait a bit until I do it :)

yaronyg commented 8 years ago

No problem. Honestly I just used CLOC and it answered my question. But I figured I would be a good Open Source user and report the bug. :)