diff options
author | Christopher Vogt <oss.nsp@cvogt.org> | 2016-03-06 23:35:57 -0500 |
---|---|---|
committer | Christopher Vogt <oss.nsp@cvogt.org> | 2016-03-06 23:35:57 -0500 |
commit | f0dc760df8757caea1d83b15142a3d0704488636 (patch) | |
tree | a3c9d8351de510d98610910862f91d8826b33ce1 /stage2/Stage2.scala | |
parent | 4dae0e69f4b2947942d5ff7d4edee482073ee26b (diff) | |
download | cbt-f0dc760df8757caea1d83b15142a3d0704488636.tar.gz cbt-f0dc760df8757caea1d83b15142a3d0704488636.tar.bz2 cbt-f0dc760df8757caea1d83b15142a3d0704488636.zip |
trap and pass exit codes throug the app, pass logger on to tests, remove the lib. qualification from Stage1 for better readability
Diffstat (limited to 'stage2/Stage2.scala')
-rw-r--r-- | stage2/Stage2.scala | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/stage2/Stage2.scala b/stage2/Stage2.scala index f3e833f..c6783d4 100644 --- a/stage2/Stage2.scala +++ b/stage2/Stage2.scala @@ -10,7 +10,7 @@ import cbt.paths._ object Stage2{ - def main(args: Array[String]) = { + def main(args: Array[String]): Unit = { val init = new Init(args) import init._ @@ -27,32 +27,33 @@ object Stage2{ } val task = argsV.lift( taskIndex ) - val context = Context( cwd, argsV.drop( taskIndex + 1 ), logger ) + val context = Context( argsV(0), argsV.drop( taskIndex + 1 ), logger ) val first = lib.loadRoot( context ) val build = first.finalBuild - 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 _) - val allTriggerFiles = triggerFiles ++ triggerCbtFiles - - logger.loop("Looping change detection over:\n - "+allTriggerFiles.mkString("\n - ")) - - lib.watch(allTriggerFiles) { - case file if triggerCbtFiles.exists(file.toString startsWith _.toString) => - 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) + val res = lib.trapExitCode{ + 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 _) + val allTriggerFiles = triggerFiles ++ triggerCbtFiles + + logger.loop("Looping change detection over:\n - "+allTriggerFiles.mkString("\n - ")) + + lib.watch(allTriggerFiles) { + case file if triggerCbtFiles.exists(file.toString startsWith _.toString) => + 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 } } |