add flag to disable guard

This commit is contained in:
Thomas Reynolds 2011-10-14 13:13:21 -07:00
parent 38c21cc82b
commit 18018bd248
3 changed files with 13 additions and 5 deletions

View file

@ -184,7 +184,7 @@ module Middleman
def self.start_server(options={}) def self.start_server(options={})
opts = { opts = {
:Port => options[:port], :Port => options[:port] || 4567,
:AccessLog => [] :AccessLog => []
} }

View file

@ -33,6 +33,8 @@ module Middleman
desc "server [-p 4567] [-e development]", "Starts the Middleman preview server" desc "server [-p 4567] [-e development]", "Starts the Middleman preview server"
method_option "environment", :aliases => "-e", :default => ENV['MM_ENV'] || ENV['RACK_ENV'] || 'development', :desc => "The environment Middleman will run under" method_option "environment", :aliases => "-e", :default => ENV['MM_ENV'] || ENV['RACK_ENV'] || 'development', :desc => "The environment Middleman will run under"
method_option "port", :aliases => "-p", :default => "4567", :desc => "The port Middleman will listen on" method_option "port", :aliases => "-p", :default => "4567", :desc => "The port Middleman will listen on"
method_option "disable-watcher", :default => false, :type => :boolean, :desc => "Don't use config.rb watcher (also disables livereload)"
method_option "livereload", :default => false, :type => :boolean, :desc => "Whether to enable Livereload or not" method_option "livereload", :default => false, :type => :boolean, :desc => "Whether to enable Livereload or not"
method_option "livereload-port", :default => "35729", :desc => "The port Livereload will listen on" method_option "livereload-port", :default => "35729", :desc => "The port Livereload will listen on"
def server def server
@ -42,10 +44,16 @@ module Middleman
livereload_options = {:port => options["livereload-port"]} livereload_options = {:port => options["livereload-port"]}
end end
Middleman::Guard.start({ params = {
:port => options[:port], :port => options[:port],
:environment => options[:environment] :environment => options[:environment]
}, livereload_options) }
if options["disable-watcher"]
Middleman.start_server(params)
else
Middleman::Guard.start(params, livereload_options)
end
end end
desc "build", "Builds the static site for deployment" desc "build", "Builds the static site for deployment"