@@ -435,25 +435,34 @@ defmodule Mix.Utils do
435
435
out_path = Path . join ( System . tmp_dir! , filename )
436
436
File . rm ( out_path )
437
437
438
- cond do
438
+ status = cond do
439
439
System . find_executable ( "wget" ) ->
440
- Mix . shell . cmd ( ~s( wget -O "#{ out_path } " "#{ path } ") )
440
+ Mix . shell . cmd ( ~s( wget -nv - O "#{ out_path } " "#{ path } ") )
441
441
System . find_executable ( "curl" ) ->
442
- Mix . shell . cmd ( ~s( curl -L -o "#{ out_path } " "#{ path } ") )
442
+ Mix . shell . cmd ( ~s( curl -s -S - L -o "#{ out_path } " "#{ path } ") )
443
443
windows? && System . find_executable ( "powershell" ) ->
444
444
command = ~s[ $client = new-object System.Net.WebClient; ] <>
445
445
~s[ $client.DownloadFile(\\ "#{ path } \\ ", \\ "#{ out_path } \\ ")]
446
446
Mix . shell . cmd ( ~s[ powershell -Command "& {#{ command } }"] )
447
447
true ->
448
- Mix . raise "wget or curl not installed, download manually: #{ path } "
448
+ Mix . shell . error "wget or curl not installed"
449
+ 1
449
450
end
450
451
452
+ check_command! ( status , path , out_path )
453
+
451
454
data = File . read! ( out_path )
452
455
File . rm! ( out_path )
453
456
data
454
457
end
455
458
456
- def windows? do
459
+ defp check_command! ( 0 , _path , _out_path ) , do: :ok
460
+ defp check_command! ( _status , path , out_path ) do
461
+ Mix . raise "Could not fetch data, please download manually from " <>
462
+ "#{ inspect path } and copy it to #{ inspect out_path } "
463
+ end
464
+
465
+ defp windows? do
457
466
match? ( { :win32 , _ } , :os . type )
458
467
end
459
468
0 commit comments