Change how config options are passed to Thor. Removes new Thor warnings from #2017

This commit is contained in:
Thomas Reynolds 2016-11-29 20:14:19 -08:00
parent 073f273fe4
commit 30217d2c04
7 changed files with 12 additions and 9 deletions

View file

@ -1,6 +1,10 @@
master master
=== ===
# 4.1.13
* Change how config options are passed to Thor. Removes new Thor warnings from #2017
# 4.1.12 # 4.1.12
* Fix broken `ignore { |p| true }` form. * Fix broken `ignore { |p| true }` form.

View file

@ -25,12 +25,10 @@ module Middleman::Cli
if setting.default.is_a?(String) || setting.default.is_a?(NilClass) if setting.default.is_a?(String) || setting.default.is_a?(NilClass)
base.class_option setting.key, base.class_option setting.key,
type: :string, type: :string,
default: :undefined,
desc: setting.description desc: setting.description
elsif setting.default.is_a?(TrueClass) || setting.default.is_a?(FalseClass) elsif setting.default.is_a?(TrueClass) || setting.default.is_a?(FalseClass)
base.class_option setting.key, base.class_option setting.key,
type: :boolean, type: :boolean,
default: :undefined,
desc: setting.description desc: setting.description
end end
end end

View file

@ -29,7 +29,7 @@ module Middleman::Cli
default: false, default: false,
desc: 'Print debug messages' desc: 'Print debug messages'
class_option :instrument, class_option :instrument,
type: :string, type: :boolean,
default: false, default: false,
desc: 'Print instrument messages' desc: 'Print instrument messages'
class_option :profile, class_option :profile,
@ -64,7 +64,7 @@ module Middleman::Cli
config[:mode] = :build config[:mode] = :build
config[:show_exceptions] = false config[:show_exceptions] = false
config[:cli_options] = cli_options.each_with_object({}) do |(k, v), sum| config[:cli_options] = cli_options.each_with_object({}) do |(k, v), sum|
sum[k] = v unless v == :undefined sum[k] = v
end end
end end

View file

@ -17,7 +17,7 @@ module Middleman::Cli
default: false, default: false,
desc: 'Print debug messages' desc: 'Print debug messages'
class_option :instrument, class_option :instrument,
type: :string, type: :boolean,
default: false, default: false,
desc: 'Print instrument messages' desc: 'Print instrument messages'
class_option :profile, class_option :profile,

View file

@ -306,6 +306,7 @@ module Middleman
execute_callbacks(:after_configuration) execute_callbacks(:after_configuration)
# Everything is stable # Everything is stable
$stderr.puts config[:exit_before_ready].inspect
execute_callbacks(:ready) unless config[:exit_before_ready] execute_callbacks(:ready) unless config[:exit_before_ready]
end end

View file

@ -143,7 +143,7 @@ module Middleman
app = ::Middleman::Application.new do app = ::Middleman::Application.new do
config[:cli_options] = cli_options.each_with_object({}) do |(k, v), sum| config[:cli_options] = cli_options.each_with_object({}) do |(k, v), sum|
sum[k] = v unless v == :undefined sum[k] = v
end end
ready do ready do
@ -162,7 +162,7 @@ module Middleman
# Hack around bower_components in root. # Hack around bower_components in root.
watcher.listener.ignore(/^bower_components/) watcher.listener.ignore(/^bower_components/)
# Hack around node_modules in root. # Hack around node_modules in root.
watcher.listener.ignore(/^node_modules/) watcher.listener.ignore(/^node_modules/)
@ -207,7 +207,7 @@ module Middleman
end end
def possible_from_cli(key, config) def possible_from_cli(key, config)
if @cli_options[key] && @cli_options[key] != :undefined if @cli_options[key]
@cli_options[key] @cli_options[key]
else else
config[key] config[key]

View file

@ -1,5 +1,5 @@
module Middleman module Middleman
# Current Version # Current Version
# @return [String] # @return [String]
VERSION = '4.1.12'.freeze unless const_defined?(:VERSION) VERSION = '4.1.13'.freeze unless const_defined?(:VERSION)
end end