From f0dc760df8757caea1d83b15142a3d0704488636 Mon Sep 17 00:00:00 2001 From: Christopher Vogt Date: Sun, 6 Mar 2016 23:35:57 -0500 Subject: trap and pass exit codes throug the app, pass logger on to tests, remove the lib. qualification from Stage1 for better readability --- stage2/Stage2.scala | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'stage2/Stage2.scala') 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 } } -- cgit v1.2.3