Skip to content

Commit 0ff6850

Browse files
author
José Valim
committed
Raise if status code != 0 and use non-verbose modes
1 parent 63f6088 commit 0ff6850

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

lib/mix/lib/mix/utils.ex

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -435,25 +435,34 @@ defmodule Mix.Utils do
435435
out_path = Path.join(System.tmp_dir!, filename)
436436
File.rm(out_path)
437437

438-
cond do
438+
status = cond do
439439
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}"))
441441
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}"))
443443
windows? && System.find_executable("powershell") ->
444444
command = ~s[$client = new-object System.Net.WebClient; ] <>
445445
~s[$client.DownloadFile(\\"#{path}\\", \\"#{out_path}\\")]
446446
Mix.shell.cmd(~s[powershell -Command "& {#{command}}"])
447447
true ->
448-
Mix.raise "wget or curl not installed, download manually: #{path}"
448+
Mix.shell.error "wget or curl not installed"
449+
1
449450
end
450451

452+
check_command!(status, path, out_path)
453+
451454
data = File.read!(out_path)
452455
File.rm!(out_path)
453456
data
454457
end
455458

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
457466
match?({:win32, _}, :os.type)
458467
end
459468

0 commit comments

Comments
 (0)