Get ack to exclude files with type ".min.js"
Asked Answered
M

2

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.

Madura answered 27/4, 2011 at 20:55 Comment(2)
The standard that I've seen is "$file-min.js", just curious as to why you can't change it?Sinistrodextral
It's complicated but changing would the extension would be more trouble than it's worth (politically).Madura
S
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.

Sinistrodextral answered 27/4, 2011 at 21:10 Comment(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! github.com/petdance/ack/pull/142Madura
T
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.

Tilden answered 24/4, 2012 at 17:15 Comment(3)
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.)Racialism
Ack 1.96 ignores -min.js files too, on my system. (Here's the source.)Tilden
You're right. In Ack 2 it was apparently fixed only recently and therefore was a problem for me. github.com/petdance/ack2/commit/d4152d0Racialism

© 2022 - 2024 — McMap. All rights reserved.