How can I force ag to find matches in node_modules?
Asked Answered
I

1

15

I'm using ag to search a git repo. It doesn't find matches under my node_modules subdirectory. Why not, and how can I control this behavior?

Italianize answered 25/9, 2015 at 21:2 Comment(0)
I
18

It turns out that ag honors the contents of the .gitignore file by default. So if node_modules is in .gitignore, ag won't search it. This is all sensible behavior, but difficult to debug if you aren't expecting it. Hopefully this post will help.

There's a good summary at the end of man ag:

IGNORING FILES

   By default, ag will ignore files whose names match patterns in  .gitig-
   nore,  .hgignore,  or  .agignore.  These  files  can be anywhere in the
   directories being searched.  Ag  also  ignores  files  matched  by  the
   svn:ignore property if svn --version is 1.6 or older. Finally, ag looks
   in $HOME/.agignore for ignore patterns. Binary  files  are  ignored  by
   default as well.

   If  you want to ignore .gitignore, .hgignore, and svn:ignore, but still
   take .agignore into account, use -U.

   Use the -t option to search all text files; -a to search all files; and
   -u to search all, including hidden files.

For my purposes ag -t seems to work well.

Italianize answered 25/9, 2015 at 21:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.