diff --git a/main/src/main/scala/sbt/internal/Continuous.scala b/main/src/main/scala/sbt/internal/Continuous.scala index bd8c4de9e..1a6790c76 100644 --- a/main/src/main/scala/sbt/internal/Continuous.scala +++ b/main/src/main/scala/sbt/internal/Continuous.scala @@ -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) diff --git a/sbt/src/sbt-test/watch/before-command/build.sbt b/sbt/src/sbt-test/watch/before-command/build.sbt new file mode 100644 index 000000000..34d88a1f9 --- /dev/null +++ b/sbt/src/sbt-test/watch/before-command/build.sbt @@ -0,0 +1,5 @@ +import java.nio.file.{ Files, Paths } + +watchBeforeCommand := { () => Files.write(Paths.get("foo"), "foo".getBytes) } + +watchOnIteration := { (_, _, _) => sbt.nio.Watch.CancelWatch } diff --git a/sbt/src/sbt-test/watch/before-command/test b/sbt/src/sbt-test/watch/before-command/test new file mode 100644 index 000000000..5bfcff311 --- /dev/null +++ b/sbt/src/sbt-test/watch/before-command/test @@ -0,0 +1,3 @@ +> ~compile + +$ exists foo