Sha256: 919d936f89f09ef44dc060d7ea8a73e02373107cd631707ec19583de003ac4b4

Contents?: true

Size: 1.4 KB

Versions: 1

Compression:

Stored size: 1.4 KB

Contents

#!/usr/bin/env ruby

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 => true, :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

1 entries across 1 versions & 1 rubygems

Version Path
middleman-2.0.0.rc5 bin/mm-server