Skip to content

Commit

Permalink
Load plugins on formatter_for_file, closes #12930
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Sep 14, 2023
1 parent e30f8df commit 6654f1b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/mix/lib/mix/tasks/format.ex
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@ defmodule Mix.Tasks.Format do
{formatter_opts_and_subs, _sources} =
eval_deps_and_subdirectories(cwd, dot_formatter, formatter_opts, [dot_formatter])

formatter_opts_and_subs = load_plugins(formatter_opts_and_subs)

find_formatter_and_opts_for_file(Path.expand(file, cwd), formatter_opts_and_subs)
end

Expand Down
18 changes: 18 additions & 0 deletions lib/mix/test/mix/tasks/format_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,24 @@ defmodule Mix.Tasks.FormatTest do
'''abc
end
"""

{formatter_function, _options} = Mix.Tasks.Format.formatter_for_file("a.ex")

assert formatter_function.("""
if true do
~W'''
foo bar baz
'''abc
end
""") == """
if true do
~W'''
foo
bar
baz
'''abc
end
"""
end)
end

Expand Down

0 comments on commit 6654f1b

Please sign in to comment.