tbillington / kondo

Cleans dependencies and build artifacts from your projects.
MIT License
1.76k stars 51 forks source link

How to ignore some directory? #89

Closed azzamsa closed 1 year ago

azzamsa commented 1 year ago

Hi.

I want to ignore some directories because I tend to run kondo $HOME.

~ took 20s
❯ kondo $(\ls --ignore=opt/nodebin)
/var/home/azzamsa/opt/nodebin Node project (5 minutes ago)
  └─ node_modules (177.8MiB)
  delete above artifact directories? ([y]es, [n]o, [a]ll, [q]uit): ^C

❯ kondo $(exa --ignore-glob ~/opt/nodebin)
/var/home/azzamsa/opt/nodebin Node project (6 minutes ago)
  └─ node_modules (177.8MiB)
  delete above artifact directories? ([y]es, [n]o, [a]ll, [q]uit): n
Projects cleaned: 0, Bytes deleted: 0.0B

Nothing works.

Any suggestions?

Thanks! :heart:

tbillington commented 1 year ago

I haven't put much thought into ignoring directories.

Is opt/nodebin part of your gitignore? It would be possible to modify kondo so that it respects gitignore when searching.

tbillington commented 1 year ago

Kondo will search recursively down each directory you provide it, so if opt is shown even if opt/nodebin is excluded, it will be found through opt, hope that makes sense.

azzamsa commented 1 year ago

It means no mechanism to tell kondo what directory to ignore?

tbillington commented 1 year ago

Not yet, but it could be added. Do you usually exclude directories by their exact path, or by glob?

How many directories do you exclude on average when you run kondo?

azzamsa commented 1 year ago

How many directories do you exclude on average when you run kondo?

one, it contains all language server installed through npm.

Not yet, but it could be added. Do you usually exclude directories by their exact path, or by glob?

So far, it is path.

tbillington commented 1 year ago

It would be possible to add an ignore argument, would something like this work? Then you wouldn't need to manually list the directories via ls/exa.

kondo --ignore-dir opt/nodebin

Just curious, do you often do any other kind of filtering/preprocessing before passing the directory list to kondo?

azzamsa commented 1 year ago

Just curious, do you often do any other kind of filtering/preprocessing before passing the directory list to Kondo?

I run Kondo once a week, and the only directory in kondo $HOME that I want to ignore is just one. So, previously, I just answer n to the interactive prompt.

tbillington commented 1 year ago

Do you also use the date filter?

tbillington commented 1 year ago

@azzamsa could you try this branch (https://github.com/tbillington/kondo/tree/ignore-dirs) and see if it handles your use-case ? thank you :)

https://github.com/tbillington/kondo/pull/90

Aziks0 commented 1 year ago

I had the same suggestion, and #90 works perfectly! @tbillington

tbillington commented 1 year ago

Okay, thanks @Aziks0 , I'll merge it. Let me know if you have any issue :)

tbillington commented 1 year ago

I'll close this issue for now.

azzamsa commented 1 year ago

kondo . --ignored-dirs opt/nodebin/ works like a charm! :tada:

tbillington commented 1 year ago

Thanks for confirming @azzamsa :)