mirror of
https://github.com/middleman/middleman.git
synced 2022-11-09 12:20:27 -05:00
Move some extension setup to ready event
This commit is contained in:
parent
3485f49f74
commit
9ed0796b4a
9 changed files with 17 additions and 8 deletions
|
@ -13,12 +13,17 @@ module Middleman::Cli
|
|||
def console
|
||||
require 'json'
|
||||
require 'middleman-core'
|
||||
require 'middleman-core/logger'
|
||||
|
||||
opts = {
|
||||
environment: options['environment']
|
||||
}
|
||||
|
||||
# Don't output info messages
|
||||
::Middleman::Logger.singleton(2, false)
|
||||
|
||||
app = ::Middleman::Application.new do
|
||||
config[:exit_before_ready] = true
|
||||
config[:environment] = opts[:environment].to_sym if opts[:environment]
|
||||
end
|
||||
|
||||
|
|
|
@ -92,6 +92,10 @@ module Middleman
|
|||
# @return [String]
|
||||
define_setting :source, 'source', 'Name of the source directory'
|
||||
|
||||
# If we should exit before ready event.
|
||||
# @return [Boolean]
|
||||
define_setting :exit_before_ready, false, 'If we should exit before ready event.'
|
||||
|
||||
# Middleman mode. Defaults to :server, set to :build by the build process
|
||||
# @return [String]
|
||||
define_setting :mode, ((ENV['MM_ENV'] && ENV['MM_ENV'].to_sym) || :server), 'Middleman mode. Defaults to :server'
|
||||
|
@ -274,7 +278,7 @@ module Middleman
|
|||
execute_callbacks(:after_configuration)
|
||||
|
||||
# Everything is stable
|
||||
execute_callbacks(:ready)
|
||||
execute_callbacks(:ready) unless config[:exit_before_ready]
|
||||
end
|
||||
|
||||
# Eval config
|
||||
|
|
|
@ -11,7 +11,7 @@ module Middleman::CoreExtensions
|
|||
app.config.define_setting :show_exceptions, ENV['TEST'] ? false : true, 'Whether to catch and display exceptions'
|
||||
end
|
||||
|
||||
def after_configuration
|
||||
def ready
|
||||
app.use ::Rack::ShowExceptions if !app.build? && app.config[:show_exceptions]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,7 +17,7 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
|
|||
def after_configuration
|
||||
# Allow specifying regexes to ignore, plus always ignore apple touch icons
|
||||
@ignore = Array(options.ignore) + [/^apple-touch-icon/]
|
||||
|
||||
|
||||
app.use ::Middleman::Middleware::InlineURLRewriter,
|
||||
id: :asset_hash,
|
||||
url_extensions: options.exts,
|
||||
|
|
|
@ -7,7 +7,7 @@ class Middleman::Extensions::AssetHost < ::Middleman::Extension
|
|||
option :sources, %w(.htm .html .php .css .js), 'List of extensions that are searched for bustable assets.'
|
||||
option :ignore, [], 'Regexes of filenames to skip adding query strings to'
|
||||
|
||||
def after_configuration
|
||||
def ready
|
||||
app.use ::Middleman::Middleware::InlineURLRewriter,
|
||||
id: :asset_host,
|
||||
url_extensions: options.exts,
|
||||
|
|
|
@ -16,7 +16,7 @@ class Middleman::Extensions::ExternalPipeline < ::Middleman::Extension
|
|||
latency: options[:latency]
|
||||
end
|
||||
|
||||
def after_configuration
|
||||
def ready
|
||||
if app.build?
|
||||
logger.info "== Executing: `#{options[:command]}`"
|
||||
watch_command!
|
||||
|
|
|
@ -9,7 +9,7 @@ class Middleman::Extensions::MinifyCss < ::Middleman::Extension
|
|||
SassCompressor
|
||||
}, 'Set the CSS compressor to use.'
|
||||
|
||||
def after_configuration
|
||||
def ready
|
||||
# Setup Rack middleware to minify CSS
|
||||
app.use Rack, compressor: options[:compressor],
|
||||
ignore: Array(options[:ignore]) + [/\.min\./],
|
||||
|
|
|
@ -9,7 +9,7 @@ class Middleman::Extensions::MinifyJavascript < ::Middleman::Extension
|
|||
::Uglifier.new
|
||||
}, 'Set the JS compressor to use.'
|
||||
|
||||
def after_configuration
|
||||
def ready
|
||||
# Setup Rack middleware to minify CSS
|
||||
app.use Rack, compressor: options[:compressor],
|
||||
ignore: Array(options[:ignore]) + [/\.min\./],
|
||||
|
|
|
@ -12,7 +12,7 @@ class Middleman::Extensions::RelativeAssets < ::Middleman::Extension
|
|||
require 'middleman-core/middleware/inline_url_rewriter'
|
||||
end
|
||||
|
||||
def after_configuration
|
||||
def ready
|
||||
app.use ::Middleman::Middleware::InlineURLRewriter,
|
||||
id: :asset_hash,
|
||||
url_extensions: options.exts,
|
||||
|
|
Loading…
Reference in a new issue