Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/watch waiting for #422 #424

Merged
merged 3 commits into from
Apr 8, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion frontend/src/main/scala/bloop/engine/Interpreter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,14 @@ object Interpreter {
}

private[bloop] def watch(project: Project, state: State, f: State => Task[State]): Task[State] = {
import state.logger
val reachable = Dag.dfs(state.build.getDagFor(project))
val allSourceDirs = reachable.iterator.flatMap(_.sourceDirectories.toList).map(_.underlying)
val watcher = new SourceWatcher(project, allSourceDirs.toList, state.logger)
val fg = (state: State) => f(state).map(state => State.stateCache.updateBuild(state))
val fg = (state: State) => f(state).map { state =>
logger.info("Waiting for source changes... (press C-c to interrupt)")
State.stateCache.updateBuild(state)
}

// Force the first execution before relying on the file watching task
fg(state).flatMap(newState => watcher.watch(newState, fg))
Expand Down