From 85beb5e97af5e055443d6ed20a3cdb4684351b5d Mon Sep 17 00:00:00 2001 From: Thibaud Guillaume-Gentil Date: Thu, 25 Nov 2010 08:52:53 +0100 Subject: [PATCH] Don't call run_on_change guard method when there is no matched files. --- lib/guard.rb | 10 ++++++---- lib/guard/watcher.rb | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/guard.rb b/lib/guard.rb index 9ed5c4b..129e5f3 100644 --- a/lib/guard.rb +++ b/lib/guard.rb @@ -30,10 +30,12 @@ module Guard Interactor.init_signal_traps listener.on_change do |files| - run do - guards.each do |guard| - paths = Watcher.match_files(guard, files) - supervised_task(guard, :run_on_change, paths) unless paths.empty? + if Watcher.match_files?(guards, files) + run do + guards.each do |guard| + paths = Watcher.match_files(guard, files) + supervised_task(guard, :run_on_change, paths) unless paths.empty? + end end end end diff --git a/lib/guard/watcher.rb b/lib/guard/watcher.rb index 593203b..5f7df7b 100644 --- a/lib/guard/watcher.rb +++ b/lib/guard/watcher.rb @@ -30,5 +30,9 @@ module Guard end end + def self.match_files?(guards, files) + guards.any? { |guard| !match_files(guard, files).empty? } + end + end end \ No newline at end of file