diff --git a/middleman-cli/bin/middleman b/middleman-cli/bin/middleman index b5d1921d..46fa5889 100755 --- a/middleman-cli/bin/middleman +++ b/middleman-cli/bin/middleman @@ -9,6 +9,9 @@ end require "middleman-core/load_paths" Middleman.setup_load_paths +require 'dotenv' +::Dotenv.load + require 'middleman-core' require 'middleman-core/logger' @@ -46,6 +49,8 @@ end ::Middleman::Logger.singleton(3) ::Middleman::Cli.config = ::Middleman::Application.new do + # + config[:environment] = (ENV['MM_ENV'] || ENV['RACK_ENV'] || 'development').to_sym config[:mode] = :config config[:exit_before_ready] = true config[:watcher_disable] = true diff --git a/middleman-cli/lib/middleman-cli/build.rb b/middleman-cli/lib/middleman-cli/build.rb index 7d5dd3af..df871ce2 100644 --- a/middleman-cli/lib/middleman-cli/build.rb +++ b/middleman-cli/lib/middleman-cli/build.rb @@ -10,7 +10,7 @@ module Middleman::Cli class_option :environment, aliases: '-e', - default: :production + default: ENV['MM_ENV'] || ENV['RACK_ENV'] || :production class_option :clean, type: :boolean, default: true, diff --git a/middleman-core/middleman-core.gemspec b/middleman-core/middleman-core.gemspec index d8f25c64..f5509c72 100644 --- a/middleman-core/middleman-core.gemspec +++ b/middleman-core/middleman-core.gemspec @@ -26,6 +26,7 @@ Gem::Specification.new do |s| s.add_dependency('fast_blank') s.add_dependency('parallel') s.add_dependency('servolux') + s.add_dependency('dotenv') # Helpers s.add_dependency('activesupport', ['~> 4.2'])