7

I minify javascript files on the fly and produce a .min.js file beside the existing file. This is a problem though when using ack as it treats these as .js files and searches them littering my results screen with minified javascript.

I've tried adding this to my .ackrc with no luck:

--type-set=minjs=.min.js                                                                                  
--nominjs

Is there any way to get ack to ignore this type of extension?

PS I do not have the option of simply renaming .min.js to .min_js or any other variation.

Jo Liss
  • 30,333
  • 19
  • 121
  • 170
Kevin Old
  • 969
  • 1
  • 9
  • 20

2 Answers2

5

It looks like a limitation in App::Ack::filetypes.

The regular expression is:

if ( $filename =~ m{\.([^\.$dir_sep_chars]+)$}o ) {

That "." in there is going to block from matching anything previous.

jshirley
  • 366
  • 1
  • 6
  • 1
    Yeah, my next step was to fork the code and see what I could do with it, then submit a pull request, but someone else beat me to it! https://github.com/petdance/ack/pull/142 – Kevin Old Apr 28 '11 at 15:06
4

Ack ignores min.js files as of version 1.96, so a simple upgrade will do the trick.

There is no option you need to set. The ignoring happens by default.

Jo Liss
  • 30,333
  • 19
  • 121
  • 170
  • Note that the extension needs to be `.min.js`, not `-min.js` which it can be for example in the case of underscore.js. (If you download it minified from the site, obviously.) – raine May 16 '13 at 15:15
  • 1
    Ack 1.96 ignores `-min.js` files too, on my system. (Here's the [source](https://github.com/petdance/ack/blob/3e498f77af7e5ab570c7954a4743fba9e6664a56/Ack.pm#L577).) – Jo Liss May 20 '13 at 04:56
  • You're right. In Ack 2 it was apparently fixed only recently and therefore was a problem for me. https://github.com/petdance/ack2/commit/d4152d0 – raine May 22 '13 at 00:49