I’m building a library that’s constantly re generating certain modules, building them from string templates. The generated modules include certain sigils that are nicely formatted using a custom plugin.
I need to format the string before it touches disk, because there are also file watchers, who would receive the event twice if I format as a second separate step. That’s why I can’t just call System.cmd("mix format") after creating the file.
Is there something equivalent to using Code.format_string!/2 but with the ability of passing a plugin list?
mix format - reads from standard input and prints to standard output. I haven’t tested it but I suspect you can use it in conjunction with heredoc and skip the writing to stdin. If you want to batch the formatting you can first write to temporary files and format them with one call to mix format.