File tree Expand file tree Collapse file tree 4 files changed +26
-14
lines changed Expand file tree Collapse file tree 4 files changed +26
-14
lines changed Original file line number Diff line number Diff line change 14
14
* [ GenServer] Do not deliver out of order messages on ` GenServer.cast/2 ` on distributed mode
15
15
* [ Mix] Do not pre-compile a Mix project if an alias was found
16
16
* [ Mix] Properly handle compilation errors in the Erlang compiler
17
+ * [ Mix] Always try to compile project if task cannot be found
17
18
18
19
* Deprecations
19
20
* [ Collectable] Deprecate ` Collectable.empty/1 ` and ` Enum.traverse/2 `
Original file line number Diff line number Diff line change @@ -52,19 +52,7 @@ defmodule Mix.CLI do
52
52
defp run_task ( name , args ) do
53
53
try do
54
54
Mix.Task . run "loadconfig"
55
-
56
- # If the task is not available, let's try to
57
- # compile the repository and then run it again.
58
- cond do
59
- Mix.Task . get ( name ) || Mix.Task . alias? ( name ) ->
60
- Mix.Task . run ( name , args )
61
- Mix.Project . get ->
62
- Mix.Task . run ( "compile" )
63
- Mix.Task . run ( name , args )
64
- true ->
65
- # Raise no task error
66
- Mix.Task . get! ( name )
67
- end
55
+ Mix.Task . run name , args
68
56
rescue
69
57
# We only rescue exceptions in the mix namespace, all
70
58
# others pass through and will explode on the users face
Original file line number Diff line number Diff line change @@ -244,7 +244,13 @@ defmodule Mix.Task do
244
244
end
245
245
246
246
defp run_task ( proj , task , args ) do
247
- module = get! ( task )
247
+ module = get ( task )
248
+
249
+ # If the task is not available, let's try to compile the project
250
+ unless module do
251
+ if proj , do: Mix.Task . run ( "compile" )
252
+ module = get! ( task )
253
+ end
248
254
249
255
if recursive ( module ) and Mix.Project . umbrella? and Mix.ProjectStack . enable_recursion do
250
256
res = recur ( fn _ -> run ( task , args ) end )
Original file line number Diff line number Diff line change @@ -3,6 +3,12 @@ Code.require_file "../test_helper.exs", __DIR__
3
3
defmodule Mix.TaskTest do
4
4
use MixTest.Case
5
5
6
+ defmodule SampleProject do
7
+ def project do
8
+ [ app: :sample , version: "0.0.1" ]
9
+ end
10
+ end
11
+
6
12
test "run/1" do
7
13
assert Mix.Task . run ( "hello" ) == "Hello, World!"
8
14
assert Mix.Task . run ( "hello" ) == :noop
@@ -16,6 +22,17 @@ defmodule Mix.TaskTest do
16
22
end
17
23
end
18
24
25
+ test "try to compile if task is missing" do
26
+ Mix.Project . push ( SampleProject , "sample" )
27
+
28
+ assert_raise Mix.NoTaskError , fn ->
29
+ Mix.Task . run ( "unknown" )
30
+ end
31
+
32
+ # Check if compile task have run
33
+ refute Mix.TasksServer . run ( { :task , "compile" , Mix.Project . get } )
34
+ end
35
+
19
36
test "clear/0" do
20
37
assert Mix.Task . run ( "hello" ) == "Hello, World!"
21
38
Mix.Task . clear
You can’t perform that action at this time.
0 commit comments