Skip to content

Commit e56f4c8

Browse files
committed
Load plugins on formatter_for_file, closes #12930
1 parent 8ed7b7b commit e56f4c8

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
@@ -306,6 +306,8 @@ defmodule Mix.Tasks.Format do
306306
{formatter_opts_and_subs, _sources} =
307307
eval_deps_and_subdirectories(cwd, dot_formatter, formatter_opts, [dot_formatter])
308308

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

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)