nerves-project / nerves_bootstrap

Nerves mix integration bootstrap and new project generator
http://nerves-project.org
Apache License 2.0
40 stars 18 forks source link

When (S)He does 'mix format', new project changes mix.exs . #268

Closed TORIFUKUKaiou closed 1 year ago

TORIFUKUKaiou commented 1 year ago

Environment

I use https://github.com/nerves-project/nerves_bootstrap/commit/690a03038d1866d7babea2a85c3ced3c7fb7f49d . I do Local development.

git clone https://github.com/nerves-project/nerves_bootstrap.git
cd nerves_bootstrap
mix do deps.get, archive.build, archive.install

cd ..
mix nerves.new hello_nerves
cd hello_nerves
mix format

hello_nerves project changes mix.exs .

hello_nerves/mix.exs

-  @all_targets [:rpi, :rpi0, :rpi2, :rpi3, :rpi3a, :rpi4, :bbb, :osd32mp1, :x86_64, :grisp2, :mangopi_mq_pro]
+  @all_targets [
+    :rpi,
+    :rpi0,
+    :rpi2,
+    :rpi3,
+    :rpi3a,
+    :rpi4,
+    :bbb,
+    :osd32mp1,
+    :x86_64,
+    :grisp2,
+    :mangopi_mq_pro
+  ]

I show my humble solution. If you all prefer this, I'm going to send a pull request tomorrow.

nerves_bootstrap/templates/new/mix.exs

-  @all_targets <%= inspect(Enum.map(targets, &elem(&1, 0))) %>
+  @all_targets [
+<%= Enum.map(targets, &elem(&1, 0)) |> Enum.map(& "    :#{&1}") |> Enum.join(",\n") %>
+  ]

Current behavior

When (S)He does 'mix format', new project changes mix.exs .

Expected behavior

When (S)He does 'mix format', new project changes nothing .

mnishiguchi commented 1 year ago

@TORIFUKUKaiou Thank you for reporting this! Your suggestion sounds good to me considering it helps those who run the command.

Maybe the code can be a slightly shorter with one iteration.

Enum.map(targets, &"    :#{elem(&1, 0)}")  |> Enum.join(",\n")

Please feel free to issue a pull request.