Skip to content

Commit f92a342

Browse files
committed
Apply changes from CR
1 parent 37433e8 commit f92a342

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed

lib/mix/lib/mix/task.ex

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -613,11 +613,8 @@ defmodule Mix.Task do
613613
child projects.
614614
"""
615615
@spec reenable(task_name) :: :ok
616-
def reenable(task) when is_atom(task) do
617-
task |> to_string() |> reenable()
618-
end
619-
620-
def reenable(task) when is_binary(task) do
616+
def reenable(task) when is_binary(task) or is_atom(task) do
617+
task = to_string(task)
621618
proj = Mix.Project.get()
622619
recursive = (module = get(task)) && recursive(module)
623620

lib/mix/lib/mix/tasks/compile.ex

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,27 @@ defmodule Mix.Tasks.Compile do
8282
@deprecated "Use Mix.Task.Compiler.compilers/1 instead"
8383
defdelegate compilers(config \\ Mix.Project.config()), to: Mix.Task.Compiler
8484

85+
@doc """
86+
Reenables given compilers so they can be executed again down the stack.
87+
88+
If an umbrella project reenables compilers, they are re-enabled for all
89+
child projects.
90+
91+
Default is `[]`, for none compilers to be reenabled.
92+
This task always re-enables `"compiler.all"`.
93+
"""
94+
@spec reenable([{:compilers, compilers}]) :: :ok when compilers: :all | [Mix.Task.task_name()]
95+
def reenable(opts \\ []) do
96+
compilers =
97+
case Keyword.get(opts, :compilers, :all) do
98+
:all -> compilers()
99+
list when is_list(list) -> list
100+
end
101+
102+
Enum.each(["compile", "compile.all"], &Mix.Task.reenable(&1))
103+
Enum.each(compilers, &Mix.Task.reenable("compile.#{&1}"))
104+
end
105+
85106
@impl true
86107
def run(["--list"]) do
87108
# Loadpaths without checks because compilers may be defined in deps.

lib/mix/test/mix/tasks/compile_test.exs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ defmodule Mix.Tasks.CompileTest do
117117
assert Mix.Tasks.Compile.run(["--verbose"]) == {:ok, []}
118118
Mix.shell().flush()
119119

120-
File.write!("lib/z.ex", """
120+
File.mkdir_p!("lib/foo")
121+
122+
File.write!("lib/foo/z.ex", """
121123
defmodule Z do
122124
def ok, do: :ok
123125
end
@@ -127,15 +129,15 @@ defmodule Mix.Tasks.CompileTest do
127129
assert {:noop, []} = Mix.Task.run("compile")
128130
refute File.regular?("_build/dev/lib/sample/ebin/Elixir.Z.beam")
129131

130-
assert :ok = Mix.Task.Compiler.reenable()
132+
assert :ok = Mix.Tasks.Compile.reenable(compilers: [])
131133
assert {:noop, []} = Mix.Task.run("compile")
132134
refute File.regular?("_build/dev/lib/sample/ebin/Elixir.Z.beam")
133135

134-
assert :ok = Mix.Task.Compiler.reenable(compilers: ["erlang"])
136+
assert :ok = Mix.Tasks.Compile.reenable(compilers: ["erlang"])
135137
assert {:noop, []} = Mix.Task.run("compile")
136138
refute File.regular?("_build/dev/lib/sample/ebin/Elixir.Z.beam")
137139

138-
assert :ok = Mix.Task.Compiler.reenable(compilers: ["elixir", "erlang"])
140+
assert :ok = Mix.Tasks.Compile.reenable()
139141
assert {:ok, []} = Mix.Task.run("compile")
140142
assert File.regular?("_build/dev/lib/sample/ebin/Elixir.Z.beam")
141143
end)

0 commit comments

Comments
 (0)