[Proposal] Make `Mix.Generator.copy_template/4` to accept `format: true` option

Skip to first unread message

Aleksei Matiushkin

Jun 6, 2024, 3:15:26 AMJun 6
to elixir-lang-core

when generating files with `Mix.Generator`, one should either be an expert in whitespace, or explicitly run `File.write!(target_file, Code.format_file!(target_file))` after the file has been generated.


Accept `format: true` as another option in a call to `Mix.Generator.copy_template/4` (technically, in a call to `Mix.Generator.create_file/2` here https://github.com/elixir-lang/elixir/blob/v1.16.3/lib/mix/lib/mix/generator.ex#L30 which would call `Code.format_string/2` as in here: https://github.com/elixir-lang/elixir/blob/v1.16.3/lib/elixir/lib/code.ex#L1014C17-L1014C32 on content.

If this fits, I can provide a PR.


If passed, the resulting file would have been 

José Valim

Jun 6, 2024, 8:07:18 AMJun 6
to elixir-l...@googlegroups.com
We should probably call `format_elixir: true` and that sounds good to me. A PR is welcome!

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-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/4d590811-ca64-4328-95ee-c0f0472d9544n%40googlegroups.com.

Aleksei Matiushkin

Jun 6, 2024, 9:21:23 AMJun 6
to elixir-lang-core
Reply all
Reply to author
0 new messages