File tree Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -58,11 +58,15 @@ defmodule Mix.CLI do
58
58
59
59
# If the task is not available, let's try to
60
60
# compile the repository and then run it again.
61
- if Mix.Task . get ( name ) do
62
- Mix.Task . run ( name , args )
63
- else
64
- Mix.Task . run ( "compile" )
65
- Mix.Task . run ( name , args )
61
+ cond do
62
+ Mix.Task . get ( name ) ->
63
+ Mix.Task . run ( name , args )
64
+ Mix.Project . get ->
65
+ Mix.Task . run ( "compile" )
66
+ Mix.Task . run ( name , args )
67
+ true ->
68
+ # Raise no task error
69
+ Mix.Task . get! ( name )
66
70
end
67
71
rescue
68
72
# We only rescue exceptions in the mix namespace, all
Original file line number Diff line number Diff line change @@ -51,6 +51,13 @@ defmodule Mix.CLITest do
51
51
end
52
52
end
53
53
54
+ test "no task error" do
55
+ in_fixture "no_mixfile" , fn ->
56
+ contents = mix ( "no_task" )
57
+ assert contents =~ "** (Mix) The task no_task could not be found\n "
58
+ end
59
+ end
60
+
54
61
test "--help smoke test" do
55
62
in_fixture "only_mixfile" , fn ->
56
63
output = mix "--help"
You can’t perform that action at this time.
0 commit comments