avoid guard on Windows for now

This commit is contained in:
Thomas Reynolds 2011-08-09 14:37:55 -07:00
parent 6ea2ffda5c
commit d2cbfc432f
4 changed files with 39 additions and 23 deletions

View file

@ -160,6 +160,19 @@ module Middleman
sandbox.class_eval(&block) if block_given? sandbox.class_eval(&block) if block_given?
sandbox sandbox
end end
def self.start_server(options={})
opts = {
:Port => options[:port],
:AccessLog => []
}
app = ::Middleman.server
app.set :environment, options[:environment].to_sym
opts[:app] = app.new
opts[:server] = 'thin'
::Rack::Server.new(opts).start
end
end end
require "middleman/version" require "middleman/version"

View file

@ -1,4 +1,5 @@
require 'thor' require 'thor'
require 'rbconfig'
module Middleman module Middleman
class CLI < Thor class CLI < Thor
@ -37,14 +38,20 @@ module Middleman
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
v1_check v1_check
if options["livereload"]
livereload_options = {:port => options["livereload-port"]}
end
Middleman::Guard.start({ if Config::CONFIG['host_os'].downcase =~ %r{mswin|mingw}
:port => options[:port], ::Middleman.start_server(options)
:environment => options[:environment] puts "== The Middleman is standing watch on port #{options[:port]}"
}, livereload_options) else
if options["livereload"]
livereload_options = {:port => options["livereload-port"]}
end
Middleman::Guard.start({
:port => options[:port],
:environment => options[:environment]
}, livereload_options)
end
end end
desc "build", "Builds the static site for deployment" desc "build", "Builds the static site for deployment"

View file

@ -38,9 +38,7 @@ module Guard
class Middleman < Guard class Middleman < Guard
def initialize(watchers = [], options = {}) def initialize(watchers = [], options = {})
super super
@options = { @options = options
:port => '4567'
}.update(options)
end end
def start def start
@ -54,18 +52,8 @@ module Guard
private private
def server_start def server_start
@server_options = {
:Port => @options[:port],
:AccessLog => []
# :AccessLog => ::WEBrick::Log.new('/dev/null'),
# :Logger => ::WEBrick::Log.new('/dev/null')
}
@server_job = fork do @server_job = fork do
app = ::Middleman.server ::Middleman.start_server(@options)
app.set :environment, @options[:environment].to_sym
@server_options[:app] = app.new
@server_options[:server] = 'thin'
::Rack::Server.new(@server_options).start
end end
puts "== The Middleman is standing watch on port #{@options[:port]}" puts "== The Middleman is standing watch on port #{@options[:port]}"

View file

@ -1,4 +1,6 @@
# -*- encoding: utf-8 -*- # -*- encoding: utf-8 -*-
require "rbconfig"
$:.push File.expand_path("../lib", __FILE__) $:.push File.expand_path("../lib", __FILE__)
require "middleman/version" require "middleman/version"
@ -51,8 +53,14 @@ eos
s.add_runtime_dependency("coffee-script", ["~> 2.2.0"]) s.add_runtime_dependency("coffee-script", ["~> 2.2.0"])
s.add_runtime_dependency("sprockets", ["2.0.0.beta.13"]) s.add_runtime_dependency("sprockets", ["2.0.0.beta.13"])
s.add_runtime_dependency("httparty", ["~> 0.7.8"]) s.add_runtime_dependency("httparty", ["~> 0.7.8"])
s.add_runtime_dependency("guard", ["~> 0.5.1"])
s.add_runtime_dependency("guard-livereload", ["~> 0.2.1"]) case Config::CONFIG['host_os'].downcase
when %r{mswin|mingw}
else
s.add_runtime_dependency("guard", ["~> 0.5.1"])
s.add_runtime_dependency("guard-livereload", ["~> 0.3.0"])
end
s.add_development_dependency("coffee-filter", ["~> 0.1.1"]) s.add_development_dependency("coffee-filter", ["~> 0.1.1"])
s.add_development_dependency("cucumber", ["~> 1.0.2"]) s.add_development_dependency("cucumber", ["~> 1.0.2"])
s.add_development_dependency("rake", ["0.8.7"]) s.add_development_dependency("rake", ["0.8.7"])