@@ -28,27 +28,32 @@ defmodule Mix.Tasks.Compile.Xref do
28
28
{ opts , _ , _ } =
29
29
OptionParser . parse ( args , switches: [ force: :boolean , warnings_as_errors: :boolean ] )
30
30
31
- warnings_as_errors =
32
- Keyword . get_lazy ( opts , :warnings_as_errors , fn ->
33
- Mix.Project . config ( ) [ :elixirc_options ] [ :warnings_as_errors ]
34
- end )
35
-
36
- if needs_xref? ( opts ) and should_exit? ( Mix.Task . run ( "xref" , [ "--warnings" ] ) , warnings_as_errors ) do
31
+ if needs_xref? ( opts ) and should_exit? ( run_xref ( ) , opts ) do
37
32
exit ( { :shutdown , 1 } )
38
33
end
39
34
40
35
write_manifest ( )
41
36
end
42
37
38
+ defp run_xref do
39
+ Mix.Task . run ( "xref" , [ "--warnings" ] )
40
+ end
41
+
43
42
defp needs_xref? ( opts ) do
44
43
! ! opts [ :force ] or Mix.Utils . stale? ( E . manifests ( ) , manifests ( ) )
45
44
end
46
45
47
- defp should_exit? ( :error , true ) ,
48
- do: true
49
- defp should_exit? ( _ , _ ) ,
46
+ defp should_exit? ( :error , opts ) ,
47
+ do: warnings_as_errors ( opts ) == true
48
+ defp should_exit? ( _ , _opts ) ,
50
49
do: false
51
50
51
+ defp warnings_as_errors ( opts ) do
52
+ Keyword . get_lazy ( opts , :warnings_as_errors , fn ->
53
+ Mix.Project . config ( ) [ :elixirc_options ] [ :warnings_as_errors ]
54
+ end )
55
+ end
56
+
52
57
@ doc """
53
58
Returns xref manifests.
54
59
"""
0 commit comments