From d5e99159f14f2fabaa399aaa9aa16e68e938ab58 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Thu, 3 May 2012 06:34:13 -0400 Subject: [PATCH] more changes --- bin/unison-watch | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/bin/unison-watch b/bin/unison-watch index 19e4bcf..0b4d55f 100755 --- a/bin/unison-watch +++ b/bin/unison-watch @@ -80,7 +80,19 @@ class UnisonProfile end def lines - @lines ||= File.readlines(File.expand_path("~/.unison/#{@which}.prf")) + return @lines if @lines + + @lines = File.readlines(File.expand_path("~/.unison/#{@which}.prf")) + + includes = [] + + @lines.each do |line| + if file = line[%r{^include (.*)}, 1] + includes += File.readlines(File.expand_path("~/.unison/#{file}")) + end + end + + @lines += includes end def paths @@ -99,26 +111,28 @@ watcher = Thread.new do while !Thread.current[:app]; sleep 0.1; end begin - watch = nil + @watch = nil + + p Thread.current[:paths] case RbConfig::CONFIG['host_os'] when /darwin/ require 'rb-fsevent' - watch = FSEvent.new - watch.watch Thread.current[:paths], :latency => 0.25 do |directories| + @watch = FSEvent.new + @watch.watch Thread.current[:paths], :latency => 0.1 do |directories| Thread.current[:app] << directories end when /linux/ require 'rb-inotify' - watch = INotify::Notifier.new + @watch = INotify::Notifier.new Thread.current[:paths].each do |path| - notifier.watch path, :recursive, :modify, :create, :delete do |event| + @watch.watch path, :recursive, :modify, :create, :delete do |event| Thread.current[:app] << event.absolute_name end end end - watch.run + @watch.run rescue => e puts e.message puts e.backtrace.join("\n")