Reinstate watchBeforeCommand callback

A user reported that the watchBeforeCommand callback was not being
invoked in sbt 1.4.{0, 1}. This was an oversight that occurred when
refactoring watch for the thin client and there previously had been no
regression test for that callback.
This commit is contained in:
Ethan Atkins 2020-10-24 10:07:13 -07:00
parent a09e6e2a25
commit 69be879684
3 changed files with 12 additions and 1 deletions

View File

@ -1327,7 +1327,10 @@ private[sbt] object ContinuousCommands {
}
private[sbt] val preWatchCommand = watchCommand(preWatch) { (channel, state) =>
watchState(state, channel).beforeCommand(state)
val ws = watchState(state, channel)
val newState = ws.beforeCommand(state)
ws.callbacks.beforeCommand()
newState
}
private[sbt] val postWatchCommand = watchCommand(postWatch) { (channel, state) =>
val cs = watchState(state, channel)

View File

@ -0,0 +1,5 @@
import java.nio.file.{ Files, Paths }
watchBeforeCommand := { () => Files.write(Paths.get("foo"), "foo".getBytes) }
watchOnIteration := { (_, _, _) => sbt.nio.Watch.CancelWatch }

View File

@ -0,0 +1,3 @@
> ~compile
$ exists foo