Skip to content

Commit

Permalink
Make :hackney an optional dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
aptinio committed Mar 5, 2023
1 parent 3341fd6 commit 6ae89ad
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ end
defp deps do
[
{:excoveralls, "~> 0.10", only: :test},
{:hackney, "~> 1.16", only: :test} # only required if posting to the coveralls.io service
]
end
```
Expand Down
15 changes: 15 additions & 0 deletions lib/excoveralls/poster.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ defmodule ExCoveralls.Poster do
end
end

if Code.ensure_loaded?(:hackney) do
defp send_file(file_name, options) do
Application.ensure_all_started(:hackney)
endpoint = options[:endpoint] || "https://coveralls.io"
Expand Down Expand Up @@ -62,4 +63,18 @@ defmodule ExCoveralls.Poster do
{:error, "Failed to upload the report to '#{endpoint}' (reason: #{inspect(reason)})."}
end
end
else
defp send_file(_, _) do
raise """
missing :hackney dependency
ExCoveralls requires :hackney to post to the coveralls.io service.
Please add :hackney to your mix.exs :deps list and run:
mix deps.get
mix deps.clean --build excoveralls
"""
end
end
end
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ defmodule ExCoveralls.Mixfile do
def deps do
[
{:jason, "~> 1.0"},
{:hackney, "~> 1.16"},
{:hackney, "~> 1.16", optional: true},
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false},
{:meck, "~> 0.8", only: :test},
{:mock, "~> 0.3.6", only: :test},
Expand Down

0 comments on commit 6ae89ad

Please sign in to comment.