diff options
author | Matt Farmer <matt@frmr.me> | 2016-03-06 12:06:07 -0500 |
---|---|---|
committer | Matt Farmer <matt@frmr.me> | 2016-03-06 12:16:45 -0500 |
commit | 6caf32697cc7048ca32d8b9ade5deffc1077addb (patch) | |
tree | f684495771890dc93293ae36199779933bf3aa48 /stage2/Stage2.scala | |
parent | 16fadcba92b1649be6e1a662f927ab62cdf201d6 (diff) | |
download | cbt-6caf32697cc7048ca32d8b9ade5deffc1077addb.tar.gz cbt-6caf32697cc7048ca32d8b9ade5deffc1077addb.tar.bz2 cbt-6caf32697cc7048ca32d8b9ade5deffc1077addb.zip |
Impl readability improvements in Stage2
Diffstat (limited to 'stage2/Stage2.scala')
-rw-r--r-- | stage2/Stage2.scala | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/stage2/Stage2.scala b/stage2/Stage2.scala index 44db3ae..f3e833f 100644 --- a/stage2/Stage2.scala +++ b/stage2/Stage2.scala @@ -1,30 +1,37 @@ package cbt -import cbt.paths._ + import java.io._ +import java.time._ +import java.time.LocalTime.now + import scala.collection.immutable.Seq +import cbt.paths._ + + object Stage2{ def main(args: Array[String]) = { - import java.time.LocalTime.now val init = new Init(args) - import java.time._ - val start = LocalTime.now() - def timeTaken = Duration.between(start, LocalTime.now()).toMillis - init.logger.stage2(s"[$now] Stage2 start") - import init._ + + val lib = new Lib(init.logger) + + init.logger.stage2(s"[$now] Stage2 start") val loop = argsV.lift(1) == Some("loop") val direct = argsV.lift(1) == Some("direct") - val taskIndex = if(loop || direct) 2 else 1 - val task = argsV.lift( taskIndex ) - val lib = new Lib(new Init(args).logger) + val taskIndex = if (loop || direct) { + 2 + } else { + 1 + } + val task = argsV.lift( taskIndex ) val context = Context( cwd, argsV.drop( taskIndex + 1 ), logger ) val first = lib.loadRoot( context ) val build = first.finalBuild - val res = if( loop ){ + val res = if (loop) { // TODO: this should allow looping over task specific files, like test files as well val triggerFiles = first.triggerLoopFiles.map(lib.realpath) val triggerCbtFiles = Seq( nailgun, stage1, stage2 ).map(lib.realpath _) @@ -32,15 +39,19 @@ object Stage2{ logger.loop("Looping change detection over:\n - "+allTriggerFiles.mkString("\n - ")) - lib.watch(allTriggerFiles){ + lib.watch(allTriggerFiles) { case file if triggerCbtFiles.exists(file.toString startsWith _.toString) => - logger.loop("Change is in CBT' own source code.") + logger.loop("Change is in CBT's own source code.") logger.loop("Restarting CBT.") scala.util.control.Breaks.break + case file if triggerFiles.exists(file.toString startsWith _.toString) => new lib.ReflectBuild( lib.loadDynamic(context) ).callNullary(task) } - } else new lib.ReflectBuild(build).callNullary(task) + } else { + new lib.ReflectBuild(build).callNullary(task) + } + init.logger.stage2(s"[$now] Stage2 end") res } |