File tree Expand file tree Collapse file tree 2 files changed +27
-6
lines changed Expand file tree Collapse file tree 2 files changed +27
-6
lines changed Original file line number Diff line number Diff line change @@ -58,12 +58,25 @@ defmodule Mix.Tasks.Do do
5858    { apps ,  args }  =  extract_apps_from_args ( args ) 
5959    show_forgotten_apps_warning ( apps ) 
6060
61-     Enum . each ( gather_commands ( args ) ,  fn  [ task  |  args ]  -> 
62-       if  apps  ==  [ ]  do 
63-         Mix.Task . run ( task ,  args ) 
64-       else 
65-         Mix.Task . run_in_apps ( task ,  apps ,  args ) 
66-       end 
61+     Enum . each ( gather_commands ( args ) ,  fn 
62+       [ task  |  args ]  -> 
63+         if  apps  ==  [ ]  do 
64+           Mix.Task . run ( task ,  args ) 
65+         else 
66+           Mix.Task . run_in_apps ( task ,  apps ,  args ) 
67+         end 
68+ 
69+       [ ]  -> 
70+         Mix . raise ( """ 
71+         One of the commands passed to "mix do" is empty. Each command passed to "mix do" must \ 
72+         have at least the task name. These are all invalid: 
73+ 
74+           mix do 
75+           mix do my_task + 
76+           mix do + my_task 
77+ 
78+         Run "mix help do" for more information. 
79+         """ ) 
6780    end ) 
6881  end 
6982
Original file line number Diff line number Diff line change @@ -13,6 +13,14 @@ defmodule Mix.Tasks.DoTest do
1313    end ) 
1414  end 
1515
16+   test  "raises if a task is empty"  do 
17+     for  args  <-  [ ~w( )  ,  ~w( +)  ,  ~w( help +)  ,  ~w( + help)  ]  do 
18+       assert_raise  Mix.Error ,  ~r" ^One of the commands passed to \" mix do\"  is empty"  ,  fn  -> 
19+         Mix.Tasks.Do . run ( args ) 
20+       end 
21+     end 
22+   end 
23+ 
1624  test  "gather_command returns a list of commands"  do 
1725    assert  gather_commands ( [ "help" ,  "+" ,  "compile" ] )  == 
1826             [ [ "help" ] ,  [ "compile" ] ] 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments