From 179a5b8770e99dd468ae5e7a1eb49fcea3b411b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Puyet?= Date: Mon, 9 Sep 2019 13:50:01 +0200 Subject: [PATCH] Fix folders update watcher with no folders to watch (#36163) * boot when there is folders to watch * raise argument error when paths are empty * add space between curly braces * Revert "add space between curly braces" This reverts commit 90cff20c87c088df4e95aa2b6c4331a469da7ce7. * Revert "raise argument error when paths are empty" This reverts commit 349adff0f5e667c3e882909ffb950f22b13cec1c. * stop lazy loading listem gem * back with any? * require listen gem at top of the file * improve * remove scope resolution operator --- .../active_support/evented_file_update_checker.rb | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/activesupport/lib/active_support/evented_file_update_checker.rb b/activesupport/lib/active_support/evented_file_update_checker.rb index 6075e0a3d3..d0b8153030 100644 --- a/activesupport/lib/active_support/evented_file_update_checker.rb +++ b/activesupport/lib/active_support/evented_file_update_checker.rb @@ -3,6 +3,7 @@ require "set" require "pathname" require "concurrent/atomic/atomic_boolean" +require "listen" module ActiveSupport # Allows you to "listen" to changes in a file system. @@ -55,16 +56,6 @@ module ActiveSupport dtw = directories_to_watch @dtw, @missing = dtw.partition(&:exist?) - if @dtw.any? - # Loading listen triggers warnings. These are originated by a legit - # usage of attr_* macros for private attributes, but adds a lot of noise - # to our test suite. Thus, we lazy load it and disable warnings locally. - silence_warnings do - require "listen" - rescue LoadError => e - raise LoadError, "Could not load the 'listen' gem. Add `gem 'listen'` to the development group of your Gemfile", e.backtrace - end - end boot! end @@ -109,9 +100,7 @@ module ActiveSupport def boot! normalize_dirs! - unless @dtw.empty? - Listen.to(*@dtw, &method(:changed)).start - end + Listen.to(*@dtw, &method(:changed)).start if @dtw.any? end def shutdown!