sloc icon indicating copy to clipboard operation
sloc copied to clipboard

please show example of excluding node_modules

Open ORESoftware opened this issue 7 years ago • 5 comments

This is NPM this is Node.js, the docs say use a regex to exclude, but what kind of regex? A JS regex?

A nice example would be excluding node_modules when running sloc against an NPM project

I am guessing this is the one:

sloc -e node_modules .

but I cannot be certain - in fact I am fairly certain this is not working, my machine is getting hot!

ORESoftware avatar Feb 16 '17 10:02 ORESoftware

I'm doing this and works fine

$ cd project-root
$ sloc --defails --exclude node_modules ./

rkmax avatar Feb 24 '17 15:02 rkmax

This should be added as an example directly on the npm and or github page.

LiamDotPro avatar Apr 24 '17 14:04 LiamDotPro

This works for me... npx sloc --format cli-table --format-option head --exclude "node_modules|build|\.svg$\.xml" ./

listenlight avatar Sep 27 '18 12:09 listenlight

Doesn't seem to be working. The issue here (and I'm suspecting @ORESoftware is doing the same) is that I am using lerna to automatically create virtual subpackages using symbolic links. sloc is unwrapping the symbolic links to the relative path (and recursively walking through the tree which will probably turn my machine into a great heater if I let it run). While it should be possible to work around this, I'm not sure if there is a one-size-fits-all workaround that would still allow for the simplicity of this tool to be preserved. Therefore, my recommendation would be for a command line flag that can treat all symlinks as nonexistant files/folders, for compatibility with lerna.

admin@Admins-MacBook-Pro ~/dev/project/foo $ sloc --exclude node_modules .

---------- Result ------------

            Physical :  29310
              Source :  20498
             Comment :  5779
 Single-line comment :  932
       Block comment :  4847
               Mixed :  90
 Empty block comment :  53
               Empty :  3176
               To Do :  57

Number of files read :  358

----------------------------

admin@Admins-MacBook-Pro ~/dev/project/foo $ mv node_modules ../foo_node_modules
admin@Admins-MacBook-Pro ~/dev/project/foo $ sloc --exclude node_modules .

---------- Result ------------

            Physical :  2583
              Source :  1965
             Comment :  330
 Single-line comment :  51
       Block comment :  279
               Mixed :  4
 Empty block comment :  1
               Empty :  293
               To Do :  0

Number of files read :  16

----------------------------

marknuzz avatar Mar 13 '19 00:03 marknuzz

We're having the same issue, and we're not using Lerna.

Celadora avatar Mar 15 '19 06:03 Celadora