Monday, January 11, 2010

 

Self executing watchr script


watchr monitors a directory tree, and triggers a user defined action whenever an observed file is modified.

Example test.watchr:
watch("lib/(.*)") { system "rake" }
Signal.trap("INT") { run_tests }

This script executes rake test whenever a file in lib/ changes.
To start watchr run watchr test.watchr on command line.

In order to execute this script itself insert a shebang and do chmod a+x test.watchr:
#!/usr/bin/env watchr
watch("lib/(.*)") { system "rake" }
Signal.trap("INT") { run_tests }

Now you execute that script with ./test.watchr.

Nice, uh? :)

Comments: Post a Comment
Links to this post:

Create a Link


<< Home

This page is powered by Blogger. Isn't yours?