Add --force-polling flag to server. Closes #730. Closes #644

This commit is contained in:
Thomas Reynolds 2013-01-13 11:56:53 -08:00
parent 428912850f
commit 1b1a5c086e
3 changed files with 11 additions and 5 deletions

View file

@ -7,6 +7,7 @@ Master
* Avoid looking in binary files for frontmatter. #728 * Avoid looking in binary files for frontmatter. #728
* Allow nested i18n files. #725 * Allow nested i18n files. #725
* Better adapt to Rack interface. #709 * Better adapt to Rack interface. #709
* Add --force-polling flag. #730, #644
3.0.9 3.0.9
==== ====

View file

@ -29,7 +29,7 @@ module Middleman::Cli
:type => :string, :type => :string,
:default => false, :default => false,
:desc => 'Print instrument messages' :desc => 'Print instrument messages'
method_option "disable-watcher", method_option :disable_watcher,
:type => :boolean, :type => :boolean,
:default => false, :default => false,
:desc => 'Disable the file change and delete watcher process' :desc => 'Disable the file change and delete watcher process'
@ -41,6 +41,10 @@ module Middleman::Cli
:type => :string, :type => :string,
:default => false, :default => false,
:desc => 'Additional paths to auto-reload when files change' :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 # Start the server
def server def server
@ -60,8 +64,9 @@ module Middleman::Cli
:environment => options["environment"], :environment => options["environment"],
:debug => options["verbose"], :debug => options["verbose"],
:instrumenting => options["instrument"], :instrumenting => options["instrument"],
:"disable-watcher" => options["disable-watcher"], :disable_watcher => options["disable_watcher"],
:reload_paths => options["reload_paths"] :reload_paths => options["reload_paths"],
:force_polling => options["force_polling"]
} }
puts "== The Middleman is loading" puts "== The Middleman is loading"

View file

@ -81,14 +81,14 @@ module Middleman
end end
def start_file_watcher def start_file_watcher
return if @options[:"disable-watcher"] return if @options[:disable_watcher]
first_run = !@listener first_run = !@listener
if first_run if first_run
# Watcher Library # Watcher Library
require "listen" require "listen"
@listener = Listen.to(Dir.pwd, :relative_paths => true) @listener = Listen.to(Dir.pwd, :relative_paths => true, :force_polling => @options[:force_polling])
end end
@listener.change do |modified, added, removed| @listener.change do |modified, added, removed|