Apply CLI options later in process. Fixes 1843
This commit is contained in:
parent
7e42954258
commit
aab7bac8a6
4 changed files with 19 additions and 17 deletions
|
@ -22,12 +22,12 @@ module Middleman::Cli
|
|||
if setting.default.is_a?(String) || setting.default.is_a?(NilClass)
|
||||
base.class_option setting.key,
|
||||
type: :string,
|
||||
default: setting.default,
|
||||
default: :undefined,
|
||||
desc: setting.description
|
||||
elsif setting.default.is_a?(TrueClass) || setting.default.is_a?(FalseClass)
|
||||
base.class_option setting.key,
|
||||
type: :boolean,
|
||||
default: setting.default,
|
||||
default: :undefined,
|
||||
desc: setting.description
|
||||
end
|
||||
end
|
||||
|
|
|
@ -63,14 +63,9 @@ module Middleman::Cli
|
|||
@app = ::Middleman::Application.new do
|
||||
config[:mode] = :build
|
||||
config[:show_exceptions] = false
|
||||
|
||||
cli_options.each do |k, v|
|
||||
setting = config.setting(k.to_sym)
|
||||
next unless setting
|
||||
|
||||
v = setting.options[:import].call(v) if setting.options[:import]
|
||||
|
||||
config[k.to_sym] = v
|
||||
config[:cli_options] = cli_options.reduce({}) do |sum, (k, v)|
|
||||
sum[k] = v unless v == :undefined
|
||||
sum
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -194,6 +194,8 @@ module Middleman
|
|||
|
||||
define_setting :skip_build_clean, proc { |p| [/\.git/].any? { |r| p =~ r } }, 'Whether some paths should not be removed during a clean build.'
|
||||
|
||||
define_setting :cli_options, {}, 'Options from the Command Line.'
|
||||
|
||||
define_setting :watcher_disable, false, 'If the Listen watcher should not run'
|
||||
define_setting :watcher_force_polling, false, 'If the Listen watcher should run in polling mode'
|
||||
define_setting :watcher_latency, nil, 'The Listen watcher latency'
|
||||
|
@ -281,6 +283,15 @@ module Middleman
|
|||
# Run any `configure` blocks for the current mode.
|
||||
execute_callbacks([:configure, config[:mode]])
|
||||
|
||||
config[:cli_options].each do |k, v|
|
||||
setting = config.setting(k.to_sym)
|
||||
next unless setting
|
||||
|
||||
v = setting.options[:import].call(v) if setting.options[:import]
|
||||
|
||||
config[k.to_sym] = v
|
||||
end
|
||||
|
||||
# Post parsing, pre-extension callback
|
||||
execute_callbacks(:after_configuration_eval)
|
||||
|
||||
|
|
|
@ -140,13 +140,9 @@ module Middleman
|
|||
)
|
||||
|
||||
app = ::Middleman::Application.new do
|
||||
cli_options.each do |k, v|
|
||||
setting = config.setting(k.to_sym)
|
||||
next unless setting
|
||||
|
||||
v = setting.options[:import].call(v) if setting.options[:import]
|
||||
|
||||
config[k.to_sym] = v
|
||||
cli_options.reduce({}) do |sum, (k, v)|
|
||||
sum[k] = v unless v == :undefined
|
||||
sum
|
||||
end
|
||||
|
||||
ready do
|
||||
|
|
Loading…
Reference in a new issue