Reputation: 1773
I have some folders (of static assets) from which I take some groups of images. With Path.wildcard/2
everything works wonderfully, but problems arise when I digest for production, then I find that all the images get duplicated.
How do I take one group (digested only) or the other (non digested)?
Upvotes: 0
Views: 65
Reputation: 15525
Assuming that the name of a digested file has the form app-8e93c8da27a19b82af2ba9d653edb2cb.js
and a non-digested file is named app.js
, this code will split all js/css files in the current directory in two lists of digested and non-digested filenames:
Path.wildcard("*.{js,css}")
|> Enum.split_with(fn filename -> Regex.match?(~r/^.+\-[0-9a-f]{32}\..+$/, filename) end)
|> IO.inspect
# {["app-8e93c8da27a19b82af2ba9d653edb2cb.js"], ["app.js"]}
Alter the Path.wildcard
argument to your needs.
Upvotes: 1