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