-
-
Save jstirk/1088625 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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