Skip to content

Instantly share code, notes, and snippets.

@jstirk
Created July 18, 2011 05:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jstirk/1088625 to your computer and use it in GitHub Desktop.
Save jstirk/1088625 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# Quick and dirty FSEvent watcher.
# Example:
# rr spec/lib/foo lib/foo 'spec spec/lib/foo/*_spec.rb'
#
# Will watch the spec/lib directory for any changes, and run the given command for each change,
# dumping the output to STDOUT.
require 'rubygems'
require 'rb-fsevent'
dirs = ARGV[0..-2]
cmd = ARGV.last
puts "Watching: #{dirs.join(' , ')}"
puts "Will Run: #{cmd}"
fsevent = FSEvent.new
fsevent.watch dirs, :latency => 5, :no_defer => true do |directories|
puts "Detected change..."
system(cmd)
end
fsevent.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment