module Build::Files

def self.run_with_fsevent(monitor, options = {}, &block)

def self.run_with_fsevent(monitor, options = {}, &block)
	require 'rb-fsevent'
	fsevent ||= FSEvent.new
	catch(:interrupt) do
		while true
			fsevent.watch monitor.roots do |directories|
				monitor.update(directories)
		
				yield
		
				if monitor.updated
					fsevent.stop
				end
			end
	
			fsevent.run
		end
	end
end