Don't expose TypedPath to users

I've decided I don't like the TypedPath interface so I'm not going to
expose it publicly.
This commit is contained in:
Ethan Atkins
2019-03-22 09:32:36 -07:00
parent 6a5f0f2af2
commit 86200345e1
4 changed files with 17 additions and 17 deletions
@@ -8,7 +8,7 @@
package sbt
import java.io.{ File, InputStream }
import java.nio.file.FileSystems
import java.nio.file.{ FileSystems, Path }
import sbt.BasicCommandStrings.{
ContinuousExecutePrefix,
@@ -366,7 +366,7 @@ object Watched {
action
case (Trigger, Some(event)) =>
logger.debug(s"Triggered by ${event.entry.typedPath.toPath}")
config.triggeredMessage(event.entry.typedPath, count).foreach(info)
config.triggeredMessage(event.entry.typedPath.toPath, count).foreach(info)
Trigger
case (Reload, Some(event)) =>
logger.info(s"Reload triggered by ${event.entry.typedPath.toPath}")
@@ -494,11 +494,11 @@ trait WatchConfig {
/**
* The optional message to log when a build is triggered.
* @param typedPath the path that triggered the build
* @param path the path that triggered the vuild
* @param count the current iteration
* @return an optional log message.
*/
def triggeredMessage(typedPath: TypedPath, count: Int): Option[String]
def triggeredMessage(path: Path, count: Int): Option[String]
/**
* The optional message to log before each watch iteration.
@@ -542,7 +542,7 @@ object WatchConfig {
preWatch: (Int, Boolean) => Watched.Action,
onWatchEvent: Event[FileCacheEntry] => Watched.Action,
onWatchTerminated: (Watched.Action, String, State) => State,
triggeredMessage: (TypedPath, Int) => Option[String],
triggeredMessage: (Path, Int) => Option[String],
watchingMessage: Int => Option[String]
): WatchConfig = {
val l = logger
@@ -562,8 +562,8 @@ object WatchConfig {
override def onWatchEvent(event: Event[FileCacheEntry]): Watched.Action = owe(event)
override def onWatchTerminated(action: Watched.Action, command: String, state: State): State =
owt(action, command, state)
override def triggeredMessage(typedPath: TypedPath, count: Int): Option[String] =
tm(typedPath, count)
override def triggeredMessage(path: Path, count: Int): Option[String] =
tm(path, count)
override def watchingMessage(count: Int): Option[String] = wm(count)
}
}
@@ -8,7 +8,7 @@
package sbt
import java.io.{ File, InputStream }
import java.nio.file.Files
import java.nio.file.{ Files, Path }
import java.util.concurrent.atomic.AtomicBoolean
import org.scalatest.{ FlatSpec, Matchers }
@@ -32,7 +32,7 @@ class WatchedSpec extends FlatSpec with Matchers {
handleInput: InputStream => Action = _ => Ignore,
preWatch: (Int, Boolean) => Action = (_, _) => CancelWatch,
onWatchEvent: Event[FileCacheEntry] => Action = _ => Ignore,
triggeredMessage: (TypedPath, Int) => Option[String] = (_, _) => None,
triggeredMessage: (Path, Int) => Option[String] = (_, _) => None,
watchingMessage: Int => Option[String] = _ => None
): WatchConfig = {
val monitor = fileEventMonitor.getOrElse {
@@ -81,7 +81,7 @@ class WatchedSpec extends FlatSpec with Matchers {
}
it should "filter events" in IO.withTemporaryDirectory { dir =>
val realDir = dir.toRealPath
val queue = new mutable.Queue[TypedPath]
val queue = new mutable.Queue[Path]
val foo = realDir.toPath.resolve("foo")
val bar = realDir.toPath.resolve("bar")
val config = Defaults.config(
@@ -92,11 +92,11 @@ class WatchedSpec extends FlatSpec with Matchers {
watchingMessage = _ => { Files.createFile(bar); Thread.sleep(5); Files.createFile(foo); None }
)
Watched.watch(NullInputStream, () => Right(true), config) shouldBe CancelWatch
queue.toIndexedSeq.map(_.toPath) shouldBe Seq(foo)
queue.toIndexedSeq shouldBe Seq(foo)
}
it should "enforce anti-entropy" in IO.withTemporaryDirectory { dir =>
val realDir = dir.toRealPath
val queue = new mutable.Queue[TypedPath]
val queue = new mutable.Queue[Path]
val foo = realDir.toPath.resolve("foo")
val bar = realDir.toPath.resolve("bar")
val config = Defaults.config(
@@ -116,7 +116,7 @@ class WatchedSpec extends FlatSpec with Matchers {
}
)
Watched.watch(NullInputStream, () => Right(true), config) shouldBe CancelWatch
queue.toIndexedSeq.map(_.toPath) shouldBe Seq(bar, foo)
queue.toIndexedSeq shouldBe Seq(bar, foo)
}
it should "halt on error" in IO.withTemporaryDirectory { dir =>
val halted = new AtomicBoolean(false)