Sha256: 0728429e73a1c12ea125523a8672951820ab85d3f1e73405bce4b1b270b8121c

Contents?: true

Size: 1.5 KB

Versions: 2

Compression:

Stored size: 1.5 KB

Contents

#!/usr/bin/env ruby

# Add our lib/ directory to the path
libdir = File.expand_path(File.join(File.dirname(File.dirname(__FILE__)), "lib"))
$LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)

# Setup RubyGems
require "rubygems"

# Core Pathname library used for traversal
require "pathname"

# Recursive method to find config.rb
def locate_middleman_root!(cwd = Pathname.new(Dir.pwd))
  return cwd.to_s if File.exists?(File.join(cwd, 'config.rb'))
  return false if cwd.root?
  locate_middleman_root!(cwd.parent)
end

# Only look for config.rb if MM_ROOT isn't set
if !ENV["MM_ROOT"] && found_path = locate_middleman_root!
  ENV["MM_ROOT"] = found_path
end

# If we've found the root, try to setup Bundler
if ENV["MM_ROOT"]
  
  # Set up gems listed in the Gemfile.
  ENV['BUNDLE_GEMFILE'] ||= File.expand_path('Gemfile', ENV["MM_ROOT"])
  require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
end

# Default command is server
ARGV.unshift("server") if ARGV.length < 1 || ARGV.first.include?("-")

begin
  # Local
  require File.expand_path(File.join(File.dirname(File.dirname(libdir)), "middleman-more", "lib", "middleman-more"))
rescue LoadError
  begin
    # Rubygems
    require "middleman-more"
  rescue LoadError
    # Require Middleman
    require 'middleman-core'
  end
end

# Automatically discover extensions in RubyGems
Middleman.load_extensions_in_path

require "middleman-core/cli"

# Change directory to the root
Dir.chdir(ENV["MM_ROOT"] || Dir.pwd) do
  
  # Start the CLI
  Middleman::Cli::Base.start
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
middleman-core-3.0.0.beta.3 bin/middleman
middleman-core-3.0.0.beta.2 bin/middleman