1

Trying to use this method to eliminate garbage files from being ack'd, however my definition does not work:

--type-set=map=.min.map
--no-map               

This still produces the result

$ ack MARK -l                       
public/js/vendor/jquery-2.1.1.min.map

Quite frustrating.

My workaround is --ignore-file=is:jquery-2.1.1.min.map

However I would like to banish all *.min.map files.

I really do not understand why ack had to invent a new flaky configuration syntax. What is wrong with supporting globs.

Community
  • 1
  • 1
Steven Lu
  • 41,389
  • 58
  • 210
  • 364

1 Answers1

4

What is wrong with supporting globs.

ack doesn't support globbing in filetype detection because globbing is different between *nix and Windows. Glob-based rules that used Unix-style globbing syntax would be confusing to Windows-based users. Perl regexes are the same across all platforms, and much more flexible than globbing.

To solve your problem of matching .min.map files, if your single extension doesn't work, you can use a regex like so:

--ignore-file=match:[.]min[.]map$

ack uses many rules like that in its default ruleset. You can use ack --dump to get a dump of ack's rules, and that can be handy to see how other filetypes are handled.

$ ack --dump | ack =match:
  --ignore-file=match:/[.-]min[.]js$/
  --ignore-file=match:/[.]css[.]map$/
  --ignore-file=match:/[.]css[.]min$/
  --ignore-file=match:/[.]js[.]map$/
  --ignore-file=match:/[.]js[.]min$/
  --ignore-file=match:/[.]min[.]css$/
  --ignore-file=match:/[._].*\.swp$/
  --ignore-file=match:/^#.+#$/
  --ignore-file=match:/core\.\d+$/
  --ignore-file=match:/~$/
Andy Lester
  • 91,102
  • 13
  • 100
  • 152
  • However I have one follow-up question: How can I set the type of all `[.]min[.]map$` files to `map`? This: `--type-set=map=[.]min[.]map$` doesn't appear to do anything. – Steven Lu Aug 10 '15 at 22:29
  • 1
    It should be `--type-set=map:match:[.]min[.]map$`. Look in the man page (or `ack --man`) for "Defining your own types". – Andy Lester Aug 11 '15 at 02:42
  • OK i see. Not sure why my existing map `--type-set=jsx=.jsx` even works at all then. – Steven Lu Aug 11 '15 at 03:13
  • Because when we went to ack 2.0, we made the old-style backward compatible with the ack 1.x syntax. – Andy Lester Aug 11 '15 at 14:38
  • Hey @AndyLester I have a question for you -- I tried configuring ack with `--ignore-dir=/absolute/path/to/dir` and it doesn't work, in fact I was even more surprised upon reading the manpage which says that nested dirs are "NOT supported"... but it works for me, but only with relative paths... – Steven Lu Aug 26 '15 at 18:42
  • I believe this is already reported at https://github.com/petdance/ack2/issues/291 – Andy Lester Aug 26 '15 at 19:42