sloc icon indicating copy to clipboard operation
sloc copied to clipboard

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

Open yaronyg opened this issue 8 years ago • 3 comments

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 avatar Oct 13 '15 16:10 yaronyg

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.

yaronyg avatar Oct 13 '15 16:10 yaronyg

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

flosse avatar Oct 13 '15 23:10 flosse

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. :)

yaronyg avatar Oct 14 '15 16:10 yaronyg