Skip to content

Commit

Permalink
fix: use File.cwd!/0 for fetching base path
Browse files Browse the repository at this point in the history
Otherwise it will fail if tests use [`in_project/3`][1] with confusing
error about the fact that `nil` cannot be used in `Path.dirname/1`.

It should work 100% of the time as Mix will work only when ran in
directory with `mix.exs` in it, and when running in umbrella it will
change directory to the sub project before running tasks.

Ref hauleth/mix_unused#25

[1]: https://hexdocs.pm/mix/Mix.Project.html#in_project/3
  • Loading branch information
hauleth committed Oct 23, 2021
1 parent 2bd08d5 commit 76d7025
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/excoveralls/path_reader.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ defmodule ExCoveralls.PathReader do
def base_path do
case Application.fetch_env(:excoveralls, :base_path) do
{:ok, base_path} -> base_path
:error -> Mix.Project.config_files() |> Enum.find(&(&1 =~ ~r/mix.exs/)) |> Path.dirname()
:error -> File.cwd!()
end
end

Expand Down

0 comments on commit 76d7025

Please sign in to comment.