Skip to content

Commit 8d082ad

Browse files
authored
Reenable tasks without side-effects, that only run code (#7855)
1 parent ca4a38f commit 8d082ad

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

lib/mix/lib/mix/tasks/do.ex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ defmodule Mix.Tasks.Do do
88
99
The comma should be followed by a space.
1010
11+
This task is automatically reenabled, so it can be called multiple times.
12+
1113
## Examples
1214
1315
The example below prints the available compilers and
@@ -18,6 +20,7 @@ defmodule Mix.Tasks.Do do
1820
"""
1921

2022
def run(args) do
23+
Mix.Task.reenable("do")
2124
Enum.each(gather_commands(args), fn [task | args] -> Mix.Task.run(task, args) end)
2225
end
2326

lib/mix/lib/mix/tasks/profile.cprof.ex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ defmodule Mix.Tasks.Profile.Cprof do
2121
mix profile.cprof -e "[1, 2, 3] |> Enum.reverse |> Enum.map(&Integer.to_string/1)"
2222
mix profile.cprof my_script.exs arg1 arg2 arg3
2323
24+
This task is automatically reenabled, so you can profile multiple times
25+
in the same Mix invocation.
26+
2427
## Command line options
2528
2629
* `--matching` - only profile calls matching the given `Module.function/arity` pattern
@@ -111,6 +114,7 @@ defmodule Mix.Tasks.Profile.Cprof do
111114

112115
def run(args) do
113116
{opts, head} = OptionParser.parse_head!(args, aliases: @aliases, strict: @switches)
117+
Mix.Task.reenable("profile.cprof")
114118

115119
Mix.Tasks.Run.run(
116120
["--no-mix-exs" | args],

lib/mix/lib/mix/tasks/profile.eprof.ex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ defmodule Mix.Tasks.Profile.Eprof do
2121
mix profile.eprof -e "[1, 2, 3] |> Enum.reverse |> Enum.map(&Integer.to_string/1)"
2222
mix profile.eprof my_script.exs arg1 arg2 arg3
2323
24+
This task is automatically reenabled, so you can profile multiple times
25+
in the same Mix invocation.
26+
2427
## Command line options
2528
2629
* `--matching` - only profile calls matching the given `Module.function/arity` pattern
@@ -123,6 +126,7 @@ defmodule Mix.Tasks.Profile.Eprof do
123126

124127
def run(args) do
125128
{opts, head} = OptionParser.parse_head!(args, aliases: @aliases, strict: @switches)
129+
Mix.Task.reenable("profile.eprof")
126130

127131
Mix.Tasks.Run.run(
128132
["--no-mix-exs" | args],

lib/mix/lib/mix/tasks/profile.fprof.ex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ defmodule Mix.Tasks.Profile.Fprof do
1919
mix profile.fprof -e Hello.world
2020
mix profile.fprof my_script.exs arg1 arg2 arg3
2121
22+
This task is automatically reenabled, so you can profile multiple times
23+
in the same Mix invocation.
24+
2225
## Command line options
2326
2427
* `--callers` - prints detailed information about immediate callers and called functions
@@ -127,6 +130,7 @@ defmodule Mix.Tasks.Profile.Fprof do
127130

128131
def run(args) do
129132
{opts, head} = OptionParser.parse_head!(args, aliases: @aliases, strict: @switches)
133+
Mix.Task.reenable("profile.fprof")
130134

131135
Mix.Tasks.Run.run(
132136
["--no-mix-exs" | args],

lib/mix/lib/mix/tasks/run.ex

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,14 @@ defmodule Mix.Tasks.Run do
4040
4141
elixir --sname hello -S mix run --no-halt
4242
43+
This task is automatically reenabled, so it can be called multiple times
44+
with different arguments.
45+
4346
## Command-line options
4447
4548
* `--config`, `-c` - loads the given configuration file
4649
* `--eval`, `-e` - evaluates the given code
47-
* `--require`, `-r` - requires pattern before running the command
50+
* `--require`, `-r` - executes the given pattern/file
4851
* `--parallel`, `-p` - makes all requires parallel
4952
* `--preload-modules` - preloads all modules defined in applications
5053
* `--no-compile` - does not compile even if files require compilation
@@ -81,6 +84,7 @@ defmodule Mix.Tasks.Run do
8184

8285
run(args, opts, head, &Code.eval_string/1, &Code.require_file/1)
8386
unless Keyword.get(opts, :halt, true), do: Process.sleep(:infinity)
87+
Mix.Task.reenable("run")
8488
:ok
8589
end
8690

0 commit comments

Comments
 (0)