summaryrefslogtreecommitdiff
path: root/scalalib/src/scalafmt/ScalafmtModule.scala
diff options
context:
space:
mode:
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]