CLOC ignore/exclude list file (.clocignore)
The best workaround I've found is to feed the contents of .clocignore
directly to --exclude-dir
. For example, if you are using bash
and have tr
available:
cloc --exclude-dir=$(tr '\n' ',' < .clocignore) .
The accepted answer didn't work for me, since I wanted to specify sub-directories as well, which is only possible by using the --not-match-d=""
regex argument. So I created a PHP file that generates the whole CLOC command using the .clocignore file (Example output)
$ php cloc.php
cloc --fullpath --not-match-d="(node_modules|App/ios|App/android)" --not-match-f="(yarn\.lock|package\.json|package\-lock\.json)" .
The script basically implodes the directory paths as a single regex string and outputs the full cloc command for copying convenience. I put it up on gist if anyone finds it useful :)
https://gist.github.com/Lukakva/a2ef7626724a809ff2859e7203accf53