Sha256: 0295892098aac6ef2210d758d56e21cfd14546f4a10c3ca4a042a7a21fadb9fd

Contents?: true

Size: 1.42 KB

Versions: 2

Compression:

Stored size: 1.42 KB

Contents

#!/usr/bin/env ruby

require "rubygems"
require "thor"
require "thor/group"

# Require Middleman
require File.join(File.dirname(__FILE__), '..', 'lib', 'middleman')

module Middleman
  class GuardServer < ::Thor::Group
    include Thor::Actions
    
    class_option :environment, :aliases => "-e", :default => ENV['MM_ENV'] || ENV['RACK_ENV'] || 'development'
    
    class_option :port, :aliases => "-p", :default => "4567"
    class_option :"livereload-port", :default => "35729"
    class_option :"livereload", :default => false, :type => :boolean
    
    def start_guard
      if !File.exists?("config.rb")
        $stderr.puts "== Error: Could not find a Middleman project config, perhaps you are in the wrong folder?"
        return
      end

      # If the old directories exists, use it, but issue warning
      if File.exists?("views") || File.exists?("public")
        $stderr.puts "== Error: The views and public folders are have been combined. Create a new 'source' folder, add the contents of views and public to it and then remove the empty views and public folders."
        return
      end

      ENV['RACK_ENV'] = options[:environment]
      
      livereload_options = {
        :port => options[:"livereload-port"]
      }
      livereload_options = nil unless options[:"livereload"] 
      
      ::Middleman::Guard.start({
        :port => options[:port],
      }, livereload_options)
    end
  end
end

Middleman::GuardServer.start

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
middleman-2.0.0.rc92 bin/mm-server
middleman-2.0.0.rc91 bin/mm-server