-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Mix.Tasks.Compile.reenable
#13771
base: main
Are you sure you want to change the base?
Changes from 2 commits
d2a74d7
d52d026
1072248
be20471
fa13177
534c622
2c46418
cbcede4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -162,4 +162,33 @@ defmodule Mix.Task.Compiler do | |||||||||||
{:noop, []} | ||||||||||||
end | ||||||||||||
end | ||||||||||||
|
||||||||||||
@doc """ | ||||||||||||
Reenables given compilers so they can be executed again down the stack. | ||||||||||||
|
||||||||||||
If an umbrella project reenables compilers, they are re-enabled for all | ||||||||||||
child projects. | ||||||||||||
|
||||||||||||
Default is `[]`, for none compilers to be reenabled. | ||||||||||||
This task always re-enables `"compiler.all"`. | ||||||||||||
""" | ||||||||||||
@spec reenable([{:compilers, compilers}]) :: :ok when compilers: :all | [Mix.Task.task_name()] | ||||||||||||
def reenable(opts \\ []) do | ||||||||||||
if not Keyword.keyword?(opts) do | ||||||||||||
IO.warn( | ||||||||||||
"Mix.Task.Compiler.reenable/1 expects a keyword list " <> | ||||||||||||
"as an argument with compilers: [compiler()], " <> | ||||||||||||
"reenabling no compiler" | ||||||||||||
) | ||||||||||||
else | ||||||||||||
compilers = | ||||||||||||
case Keyword.get(opts, :compilers, []) do | ||||||||||||
:all -> Mix.Tasks.Compile.compilers() | ||||||||||||
list when is_list(list) -> list | ||||||||||||
end | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's go with all by default, because it is easier to customize.
Suggested change
I am also thinking we should move this function to |
||||||||||||
|
||||||||||||
Enum.each(["loadpaths", "compile", "compile.all"], &Mix.Task.reenable(&1)) | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am unsure if we should enable loadpaths. Thoughts? Why not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We should not. It is a leftover from the code when I thought the enabling should be mirrored by a roll-back, but it should not in the latest approach. I cannot think of any change resulting in a need to reload paths from within same external task execution, even if it calls |
||||||||||||
Enum.each(compilers, &Mix.Task.reenable("compile.#{&1}")) | ||||||||||||
end | ||||||||||||
end | ||||||||||||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -613,8 +613,11 @@ defmodule Mix.Task do | |
child projects. | ||
""" | ||
@spec reenable(task_name) :: :ok | ||
def reenable(task) when is_binary(task) or is_atom(task) do | ||
task = to_string(task) | ||
def reenable(task) when is_atom(task) do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove the changes to this function. :) |
||
task |> to_string() |> reenable() | ||
end | ||
|
||
def reenable(task) when is_binary(task) do | ||
proj = Mix.Project.get() | ||
recursive = (module = get(task)) && recursive(module) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to check for the arguments.