summaryrefslogtreecommitdiff
path: root/scalalib/src/scalafmt/ScalafmtModule.scala
diff options
context:
space:
mode:
authorJakob Odersky <jakob@inpher.io>2019-09-30 19:21:21 -0400
committerJakob Odersky <jakob@inpher.io>2019-11-20 12:13:52 -0500
commit5e062b7e9e50cc6a1dbb12291fbc2643a59a0210 (patch)
tree4f7bb7c37f6588381a79e2e7d055c921ab608703 /scalalib/src/scalafmt/ScalafmtModule.scala
parent2b5c2465544e318c225d748a3c73b244978ed98c (diff)
downloadmill-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.scala20
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]