I can think of two alternative approaches:
Post process getDirectoryContents
Call getDirectoryContents
then filter out the values you don't care about. Something like:
xs <- getDirectoryFiles "" ["//*.js"]
need [x -<.> "min.js" | x <- xs, takeExtensions x == ".js"]
If you are running this code outside of a rule, e.g. in an action
, then it is 100% correct. If you are running the code in a rule then the rule will run once, new files will appear, and then the rule will run again (which is also a lint violation, and not great build hygine). I suspect you are running outside of a rule, so this approach is probably a good one.
Write an Oracle
If you are inside a rule, you can define an Oracle which is like getDirectoryFiles
, but skips the min
files.
newtype JsFiles = JsFiles () deriving (Show,Typeable,Eq,Hashable,Binary,NFData)
addOracle $ \(JsFiles _) -> fmap (\x -> takeExtensions x == ".js") $ getDirectoryFiles "" ["//*.js"]
Now you can use askOracle $ JsFiles ()
in your rule, and it will only change when new non-min
files are added.