Skip to content

Commit 69eaa82

Browse files
committed
Fix Dialyzer warning in generated project
Dialyzer now detects that either the host or target-specific supervision tree children are unused. This moves the code to a compile-time check and updates the comments.
1 parent a9d2cb4 commit 69eaa82

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

templates/new/lib/app_name/application.ex

+19-15
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ defmodule <%= app_module %>.Application do
1212
# Children for all targets
1313
# Starts a worker by calling: <%= app_module %>.Worker.start_link(arg)
1414
# {<%= app_module %>.Worker, arg},
15-
] ++ children(Nerves.Runtime.mix_target())
15+
] ++ target_children()
1616

1717
# See https://hexdocs.pm/elixir/Supervisor.html
1818
# for other strategies and supported options
@@ -21,19 +21,23 @@ defmodule <%= app_module %>.Application do
2121
end
2222

2323
# List all child processes to be supervised
24-
defp children(:host) do
25-
[
26-
# Children that only run on the host
27-
# Starts a worker by calling: <%= app_module %>.Worker.start_link(arg)
28-
# {<%= app_module %>.Worker, arg},
29-
]
30-
end
31-
32-
defp children(_target) do
33-
[
34-
# Children for all targets except host
35-
# Starts a worker by calling: <%= app_module %>.Worker.start_link(arg)
36-
# {<%= app_module %>.Worker, arg},
37-
]
24+
if Mix.target() == :host do
25+
defp target_children() do
26+
[
27+
# Children that only run on the host during development or test.
28+
# In general, prefer using `config/host.exs` for differences.
29+
#
30+
# Starts a worker by calling: Host.Worker.start_link(arg)
31+
# {Host.Worker, arg},
32+
]
33+
end
34+
else
35+
defp target_children() do
36+
[
37+
# Children for all targets except host
38+
# Starts a worker by calling: Target.Worker.start_link(arg)
39+
# {Target.Worker, arg},
40+
]
41+
end
3842
end
3943
end

0 commit comments

Comments
 (0)