6

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.

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
Arg
  • 1,926
  • 21
  • 32

1 Answers1

8

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
Nicolas Cortot
  • 6,591
  • 34
  • 44