There is a callback that you implement for your modules called __mix_recompile__? Which you can implement with your own logic to detect how files and directories change. You can See how embed_templates does it for examples. :)
On Thu, Oct 19, 2023 at 11:01 'Alexander Steppke' via elixir-lang-core < elixir-lang-core@googlegroups.com> wrote: > We have a need to trigger recompilation of a module when any file inside a > directory is added or removed since we add the list of files at compilation > time as a module attribute which is used in guard statements. > > Something like > > ``` > defmodule Example do > @files File.ls!("some-path") > end > ``` > > I think Phoenix's `embed_templates` would have to use a similar feature if > Phoenix didn't take care of triggering recompilation itself. > > Implementation wise I'd think it might probably suffice to set the > `digest` as the hash of the list of files (probably recursively?) in the > directory, but there might be better ways to do this. > > If there is another already existing way to achieve the same please let me > know, maybe I'm just missing something! > > Best regards, Alex. > > -- > You received this message because you are subscribed to the Google Groups > "elixir-lang-core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to elixir-lang-core+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elixir-lang-core/743e4012-af1b-437d-8277-97cd5bb302aan%40googlegroups.com > <https://groups.google.com/d/msgid/elixir-lang-core/743e4012-af1b-437d-8277-97cd5bb302aan%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4%2Bo%2B14PRyaheX48QjTvP%2BF%2BL4h38MWi%3DvvwaSkGz1XouQ%40mail.gmail.com.