Skip to content

Commit

Permalink
update(Formatter): Prefer Code
Browse files Browse the repository at this point in the history
use Code instead of invoking the mix task.
  • Loading branch information
ckoch-cars committed Aug 20, 2022
1 parent 1393876 commit 303bcba
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/ex_factor/formatter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ defmodule ExFactor.Formatter do

def format([nil], _opts), do: nil

def format(args, opts) do
def format(paths, opts) do
if Keyword.get(opts, :format, true) do
Mix.Tasks.Format.run(args)
Enum.map(paths, fn path ->
path
|> Code.format_file!()
|> then(fn contents ->
File.write!(path, contents, [:write])
end)
end)
end
end
end

0 comments on commit 303bcba

Please sign in to comment.