Attempt address #466 and avoid Bundler issues with RVM

This commit is contained in:
Thomas Reynolds 2012-06-13 20:33:50 -07:00
parent 2e5ae051e6
commit 862a56a343
2 changed files with 25 additions and 19 deletions

View file

@ -22,6 +22,8 @@ if !ENV["MM_ROOT"] && found_path = locate_root
ENV["MM_ROOT"] = found_path ENV["MM_ROOT"] = found_path
end end
is_bundler_setup = false
# If we've found the root, try to setup Bundler # If we've found the root, try to setup Bundler
if ENV["MM_ROOT"] if ENV["MM_ROOT"]
@ -33,12 +35,20 @@ if ENV["MM_ROOT"]
ENV['BUNDLE_GEMFILE'] = git_gemfile.to_s ENV['BUNDLE_GEMFILE'] = git_gemfile.to_s
end end
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) if File.exists?(ENV['BUNDLE_GEMFILE'])
is_bundler_setup = true
require 'bundler/setup'
end
end end
# Automatically discover extensions in RubyGems # Automatically discover extensions in RubyGems
require "middleman-core/extensions" require "middleman-core/extensions"
::Middleman.load_extensions_in_path
if is_bundler_setup
Bundler.require
else
::Middleman.load_extensions_in_path
end
require "middleman-core/cli" require "middleman-core/cli"

View file

@ -58,23 +58,19 @@ module Middleman
# #
# @private # @private
def load_extensions_in_path def load_extensions_in_path
if defined?(Bundler) require "rubygems"
Bundler.require
else begin
require "rubygems" require "middleman-more"
rescue LoadError
begin end
require "middleman-more"
rescue LoadError extensions = rubygems_latest_specs.select do |spec|
end spec_has_file?(spec, EXTENSION_FILE)
end
extensions = rubygems_latest_specs.select do |spec|
spec_has_file?(spec, EXTENSION_FILE) extensions.each do |spec|
end require spec.name
extensions.each do |spec|
require spec.name
end
end end
end end