Skip to content

Commit 6654f1b

Browse files
committed
Load plugins on formatter_for_file, closes #12930
1 parent e30f8df commit 6654f1b

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lib/mix/lib/mix/tasks/format.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,8 @@ defmodule Mix.Tasks.Format do
307307
{formatter_opts_and_subs, _sources} =
308308
eval_deps_and_subdirectories(cwd, dot_formatter, formatter_opts, [dot_formatter])
309309

310+
formatter_opts_and_subs = load_plugins(formatter_opts_and_subs)
311+
310312
find_formatter_and_opts_for_file(Path.expand(file, cwd), formatter_opts_and_subs)
311313
end
312314

lib/mix/test/mix/tasks/format_test.exs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,24 @@ defmodule Mix.Tasks.FormatTest do
308308
'''abc
309309
end
310310
"""
311+
312+
{formatter_function, _options} = Mix.Tasks.Format.formatter_for_file("a.ex")
313+
314+
assert formatter_function.("""
315+
if true do
316+
~W'''
317+
foo bar baz
318+
'''abc
319+
end
320+
""") == """
321+
if true do
322+
~W'''
323+
foo
324+
bar
325+
baz
326+
'''abc
327+
end
328+
"""
311329
end)
312330
end
313331

0 commit comments

Comments
 (0)