1 Reply Latest reply on Oct 28, 2013 2:58 PM by Jon Tara

    excludedir negation/"includedir"

    Jon Tara

      There seems to be a blind spot in the excluddir feature of build.yml.

       

      This relies on Ruby directory globs, documented in Dir#glob and File#fnmatch. These do not have full regex capability, just similar to shell globs, which only a few regex features. (character classes, for example.)


      Ruby file globs lack any pattern negation capability, though, other than character-set negation, like [^abc]. So, there is no way to exclude all files that match a pattern, except for certain files.


      I'm concatenating and minifying all of our .js files, and, thus, I want to exclude all .js files except for main.min.js.


      The current capability leaves me with no choice but to exhaustively list the .js files that are to be excluded. OK, that's easy for me to do, because I do some pre-processing with Mustache, and the list of JS files is available in a Mustache array, and I can just drop that list into build.yml. But would be nicer if there were some negation capability or "includedir" which would override "excludedir".


      I don't want to delete the .js files from the source directory. They are pre-processed, and might have Mustache substitutions, and so I want them there for the developer to examine. But I don't want them copied to the executable bundle.


      One way around this would be to put all the JS in a subdirectory, say /app/public/js/source, exclude that directory, and put the minified version in /app/public. But, actually, we have .js files sprinkled through our models (to keep them near where they are used) , plus jQuery/jQuery Mobile, so that nixes that plan.


      And I don't want to use this ugly solution: "**/*[^m][^i][^n].js" since it would require all JS files to have at least 3 letters...


      Anybody have a trick for handling this?


      Really what is needed is "includedir", which would take a glob pattern and override "excludedir".