Skip to content

Commit 309c19a

Browse files
Albert Meltzerkitbellew
authored andcommitted
Do not invoke formatting on empty list of files
1 parent 42b9ee2 commit 309c19a

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

plugin/src/main/scala/org/scalafmt/sbt/ScalafmtPlugin.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,12 +406,15 @@ object ScalafmtPlugin extends AutoPlugin {
406406
private def getScalafmtSourcesTask(
407407
f: Seq[File] => Def.Initialize[Task[Unit]]
408408
) = Def.taskDyn[Unit] {
409-
(unmanagedSources in scalafmt).?.value.map(f).getOrElse(Def.task(Unit))
409+
val sources = (unmanagedSources in scalafmt).?.value
410+
sources.filter(_.nonEmpty).map(f).getOrElse(Def.task(Unit))
410411
}
411412

412413
private def getScalafmtSbtTasks(
413-
f: (Seq[File], Path) => Def.Initialize[Task[Unit]]
414+
func: (Seq[File], Path) => Def.Initialize[Task[Unit]]
414415
) = Def.taskDyn[Unit] {
416+
def f(files: Seq[File], config: Path) =
417+
if (files.isEmpty) Def.task[Unit]() else func(files, config)
415418
Def.sequential(
416419
f(sbtSources.value, sbtConfig.value),
417420
f(metabuildSources.value, scalaConfig.value)

0 commit comments

Comments
 (0)