diff options
author | Jakob Odersky <jakob@inpher.io> | 2019-09-30 19:21:21 -0400 |
---|---|---|
committer | Jakob Odersky <jakob@inpher.io> | 2019-11-20 12:13:52 -0500 |
commit | 5e062b7e9e50cc6a1dbb12291fbc2643a59a0210 (patch) | |
tree | 4f7bb7c37f6588381a79e2e7d055c921ab608703 /scalalib/src/scalafmt/ScalafmtModule.scala | |
parent | 2b5c2465544e318c225d748a3c73b244978ed98c (diff) | |
download | mill-5e062b7e9e50cc6a1dbb12291fbc2643a59a0210.tar.gz mill-5e062b7e9e50cc6a1dbb12291fbc2643a59a0210.tar.bz2 mill-5e062b7e9e50cc6a1dbb12291fbc2643a59a0210.zip |
Add task to only check formatting of Scala filesscalafmt-check
Diffstat (limited to 'scalalib/src/scalafmt/ScalafmtModule.scala')
-rw-r--r-- | scalalib/src/scalafmt/ScalafmtModule.scala | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/scalalib/src/scalafmt/ScalafmtModule.scala b/scalalib/src/scalafmt/ScalafmtModule.scala index ea254e6d..ec67ff18 100644 --- a/scalalib/src/scalafmt/ScalafmtModule.scala +++ b/scalalib/src/scalafmt/ScalafmtModule.scala @@ -15,6 +15,15 @@ trait ScalafmtModule extends JavaModule { ) } + def checkFormat(): Command[Unit] = T.command { + ScalafmtWorkerModule + .worker() + .checkFormat( + filesToFormat(sources()), + scalafmtConfig().head + ) + } + def scalafmtConfig: Sources = T.sources(os.pwd / ".scalafmt.conf") protected def filesToFormat(sources: Seq[PathRef]) = { @@ -39,6 +48,17 @@ object ScalafmtModule extends ExternalModule with ScalafmtModule { ) } + def checkFormatAll(sources: mill.main.Tasks[Seq[PathRef]]): Command[Unit] = + T.command { + val files = Task.sequence(sources.value)().flatMap(filesToFormat) + ScalafmtWorkerModule + .worker() + .checkFormat( + files, + scalafmtConfig().head + ) + } + implicit def millScoptTargetReads[T] = new mill.main.Tasks.Scopt[T]() lazy val millDiscover = Discover[this.type] |