Reputation: 1916
Is there a way to run a task on every code change in a given directory? Preferably, something that works well with ~
operator in SBT so that I could do:
~jadeCompile
to run custom jadeCompile
task.
Upvotes: 6
Views: 551
Reputation: 6701
Take a look at the documentation for triggered execution. You can configure the watched directory using the watchSources
setting. This is a bit trickier as only Scala source files will be watched by default, so we need to specify an appropriate path finder:
watchSources <++= baseDirectory map { path =>
((path / "src/main/jade") ** "*.jade").get }
The watchSources
setting is not scoped, so you will need to watch all sources at once. Then you just have to run:
~jadeCompile
Upvotes: 8