【问题标题】:How can I force ag to find matches in node_modules?如何强制 ag 在 node_modules 中查找匹配项?
【发布时间】:2015-09-25 21:02:39
【问题描述】:

我正在使用 ag 来搜索 git repo。它在我的node_modules 子目录下找不到匹配项。为什么不呢,我该如何控制这种行为?

【问题讨论】:

    标签: ag


    【解决方案1】:

    事实证明,默认情况下,ag 尊重 .gitignore 文件的内容。所以如果node_modules.gitignore 中,ag 就不会搜索它。这都是明智的行为,但如果您不期待它,则很难调试。希望这篇文章会有所帮助。

    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.
    

    就我的目的而言,ag -t 似乎运作良好。

    【讨论】:

      猜你喜欢
      • 2012-11-07
      • 1970-01-01
      • 2017-12-05
      • 2012-07-21
      • 1970-01-01
      • 2020-02-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多