Moved Guard::Listener#update_last_event inside Guard::Listener#modified_files
Since the pattern was to always call Guard::Listener#update_last_event after Guard::Listener#modified_files.
This commit is contained in:
parent
a318e03ad1
commit
8a1ca41626
@ -50,8 +50,7 @@ module Guard
|
||||
end
|
||||
|
||||
# Reparse the whole directory to catch new files modified during the guards run
|
||||
new_modified_files = listener.modified_files([Dir.pwd + '/'], :all => true)
|
||||
listener.update_last_event
|
||||
new_modified_files = listener.modified_files([Dir.pwd], :all => true)
|
||||
if !new_modified_files.empty? && Watcher.match_files?(guards, new_modified_files)
|
||||
run { run_on_change_for_all_guards(new_modified_files) }
|
||||
end
|
||||
|
@ -46,9 +46,10 @@ module Guard
|
||||
@last_event = Time.now
|
||||
end
|
||||
|
||||
def modified_files(dirs, options = {})
|
||||
def modified_files(dirs, options={})
|
||||
files = potentially_modified_files(dirs, options).select { |path| file_modified?(path) }
|
||||
relativate_paths files
|
||||
update_last_event
|
||||
relativize_paths(files)
|
||||
end
|
||||
|
||||
def worker
|
||||
|
@ -38,10 +38,9 @@ module Guard
|
||||
private
|
||||
|
||||
def watch(directory)
|
||||
worker.watch directory do |modified_dirs|
|
||||
worker.watch(directory) do |modified_dirs|
|
||||
files = modified_files(modified_dirs)
|
||||
update_last_event
|
||||
callback.call(files)
|
||||
@callback.call(files) unless files.empty?
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -65,9 +65,8 @@ module Guard
|
||||
sleep latency
|
||||
inotify.process
|
||||
|
||||
modified_files = modified_files(files.shift(files.size).map{|f| File.dirname(f) + '/' }.uniq)
|
||||
update_last_event
|
||||
callback.call(modified_files) unless modified_files.empty?
|
||||
files = modified_files(@files.shift(@files.size).map { |f| File.dirname(f) }.uniq)
|
||||
@callback.call(files) unless files.empty?
|
||||
end
|
||||
end
|
||||
@watch_change = false
|
||||
|
@ -24,9 +24,8 @@ module Guard
|
||||
until @stop
|
||||
start = Time.now.to_f
|
||||
files = modified_files([Dir.pwd + '/'], :all => true)
|
||||
update_last_event
|
||||
callback.call(relativate_paths(files)) unless files.empty?
|
||||
nap_time = latency - (Time.now.to_f - start)
|
||||
@callback.call(files) unless files.empty?
|
||||
sleep(nap_time) if nap_time > 0
|
||||
end
|
||||
end
|
||||
|
@ -35,9 +35,9 @@ module Guard
|
||||
def watch(directory)
|
||||
worker.watch(directory, :all_events, :recursive) do |event|
|
||||
paths = [File.expand_path(event.watcher.path) + '/']
|
||||
files = modified_files(paths, {:all => true})
|
||||
update_last_event
|
||||
callback.call(files)
|
||||
paths = [File.expand_path(event.watcher.path)]
|
||||
files = modified_files(paths, :all => true)
|
||||
@callback.call(files) unless files.empty?
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user