From d4f5e4db295494b1bf9231e13655716ce61fb0dd Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Sun, 13 Jan 2013 11:56:53 -0800 Subject: [PATCH] Add --force-polling flag to server. Closes #730. Closes #644 --- CHANGELOG.md | 1 + middleman-core/lib/middleman-core/cli/server.rb | 11 ++++++++--- middleman-core/lib/middleman-core/preview_server.rb | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 65602443..51b454c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Master * Avoid looking in binary files for frontmatter. #728 * Allow nested i18n files. #725 * Better adapt to Rack interface. #709 +* Add --force-polling flag. #730, #644 3.0.9 ==== diff --git a/middleman-core/lib/middleman-core/cli/server.rb b/middleman-core/lib/middleman-core/cli/server.rb index 81edf838..e69c9970 100644 --- a/middleman-core/lib/middleman-core/cli/server.rb +++ b/middleman-core/lib/middleman-core/cli/server.rb @@ -29,7 +29,7 @@ module Middleman::Cli :type => :string, :default => false, :desc => 'Print instrument messages' - method_option "disable-watcher", + method_option :disable_watcher, :type => :boolean, :default => false, :desc => 'Disable the file change and delete watcher process' @@ -41,6 +41,10 @@ module Middleman::Cli :type => :string, :default => false, :desc => 'Additional paths to auto-reload when files change' + method_option :force_polling, + :type => :boolean, + :default => false, + :desc => 'Force file watcher into polling mode' # Start the server def server @@ -60,8 +64,9 @@ module Middleman::Cli :environment => options["environment"], :debug => options["verbose"], :instrumenting => options["instrument"], - :"disable-watcher" => options["disable-watcher"], - :reload_paths => options["reload_paths"] + :disable_watcher => options["disable_watcher"], + :reload_paths => options["reload_paths"], + :force_polling => options["force_polling"] } puts "== The Middleman is loading" diff --git a/middleman-core/lib/middleman-core/preview_server.rb b/middleman-core/lib/middleman-core/preview_server.rb index 2d5d0153..5f53c5ed 100644 --- a/middleman-core/lib/middleman-core/preview_server.rb +++ b/middleman-core/lib/middleman-core/preview_server.rb @@ -80,14 +80,14 @@ module Middleman end def start_file_watcher - return if @options[:"disable-watcher"] + return if @options[:disable_watcher] first_run = !@listener if first_run # Watcher Library require "listen" - @listener = Listen.to(Dir.pwd, :relative_paths => true) + @listener = Listen.to(Dir.pwd, :relative_paths => true, :force_polling => @options[:force_polling]) end @listener.change do |modified, added, removed|