-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: skip unknown deps in dot formatter
- Loading branch information
1 parent
479ccc0
commit bdcb047
Showing
3 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
defmodule Igniter.Rewrite.DotFormatterUpdater do | ||
@moduledoc false | ||
|
||
alias Rewrite.DotFormatter | ||
|
||
@behaviour Rewrite.Hook | ||
|
||
@formatter ".formatter.exs" | ||
|
||
@impl true | ||
def handle(:new, project) do | ||
{:ok, %{project | dot_formatter: dot_formatter(project)}} | ||
end | ||
|
||
def handle({action, files}, project) when action in [:added, :updated] do | ||
if dot_formatter?(files) do | ||
{:ok, %{project | dot_formatter: dot_formatter(project)}} | ||
else | ||
:ok | ||
end | ||
end | ||
|
||
defp dot_formatter(project) do | ||
case DotFormatter.read(project, ignore_unknown_deps: true) do | ||
{:ok, dot_formatter} -> dot_formatter | ||
{:error, _error} -> DotFormatter.default() | ||
end | ||
end | ||
|
||
defp dot_formatter?(@formatter), do: true | ||
defp dot_formatter?(files) when is_list(files), do: Enum.member?(files, @formatter) | ||
defp dot_formatter?(_files), do: false | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters