facebookincubator / fastmod

A fast partial replacement for the codemod tool
Apache License 2.0
1.66k stars 41 forks source link

Can fastmod also modify hidden files? #30

Closed kkom closed 3 years ago

kkom commented 3 years ago

In our codebase we have some committed .env files (it's a separate question whether that's a good idea or not...).

➜  fastmod-dot-env ls -al
total 16
drwxr-xr-x   4 konradkomorowski  staff  128 25 May 14:52 .
drwx------@ 25 konradkomorowski  staff  800 25 May 14:50 ..
-rw-r--r--   1 konradkomorowski  staff    4 25 May 14:50 .foo
-rw-r--r--   1 konradkomorowski  staff    4 25 May 14:52 foo
➜  fastmod-dot-env cat .foo 
bar
➜  fastmod-dot-env cat foo 
bar

I noticed that fastmod will ignore those:

➜  fastmod-dot-env fastmod --accept-all bar baz
➜  fastmod-dot-env cat .foo 
bar
➜  fastmod-dot-env cat foo 
baz

things work fine if I'm directly targeting that file:

➜  fastmod-dot-env fastmod --accept-all bar baz .foo 
➜  fastmod-dot-env cat .foo 
baz

But sometimes I don't know what the filenames will be (as in the case of the codemod we were running), and we are 100% confident that we want to just replace all substrings.

I tried options like -g **/* and -g */** but that didn't work.

What's the motivation for this behavior? Is there a workaround that I'm not aware of?

PS: here's my version

➜  fastmod-dot-env fastmod --version
fastmod 0.4.1
swolchok commented 3 years ago

The --hidden flag was added in fastmod 0.4.2. https://github.com/facebookincubator/fastmod/commit/4d2e36298e074b9ad55a54aecde3ca895ed26f73

swolchok commented 3 years ago

What's the motivation for this behavior?

It's the default behavior of the ignore crate, which we use to walk the filesystem (and thus of the ripgrep tool as well). We are slowly creeping toward supporting all of ripgrep's options for modifying the directory walk.

kkom commented 3 years ago

oh, wow, I'm sorry for not having checked the very latest version... who knew that it would be just added

well, thank you for the explanation!