fix errant MM bootup during CLI. Make an autodiscoverable tasks/ directory
This commit is contained in:
parent
aeb9d10b25
commit
d1f0e6f616
|
@ -1,10 +0,0 @@
|
|||
class HelloWorld < Thor
|
||||
default_task :say_hi
|
||||
|
||||
desc "hello", "Say hello"
|
||||
def say_hi
|
||||
puts "Hello World"
|
||||
end
|
||||
end
|
||||
|
||||
Middleman::Cli::Base.register(HelloWorld, :hello, "hello", "Say hello")
|
|
@ -0,0 +1,6 @@
|
|||
class Hello < Thor
|
||||
desc "hello", "Say hello"
|
||||
def hello
|
||||
puts "Hello World"
|
||||
end
|
||||
end
|
|
@ -45,8 +45,22 @@ module Middleman::Cli
|
|||
end
|
||||
|
||||
klass, task = Thor::Util.find_class_and_task_by_namespace("#{meth}:#{meth}")
|
||||
args.unshift(task) if task
|
||||
klass.start(args, :shell => self.shell)
|
||||
|
||||
if klass.nil?
|
||||
tasks_dir = File.join(Dir.pwd, "tasks")
|
||||
|
||||
if File.exists?(tasks_dir)
|
||||
Dir[File.join(tasks_dir, "**/*_task.rb")].each { |f| require f }
|
||||
klass, task = Thor::Util.find_class_and_task_by_namespace("#{meth}:#{meth}")
|
||||
end
|
||||
end
|
||||
|
||||
if klass.nil?
|
||||
super
|
||||
else
|
||||
args.unshift(task) if task
|
||||
klass.start(args, :shell => self.shell)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -85,10 +85,12 @@ module Middleman::Cli
|
|||
sess
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Set the root path to the Middleman::Base's root
|
||||
source_root(shared_instance.root)
|
||||
# Set the root path to the Middleman::Base's root
|
||||
def source_root
|
||||
shared_instance.root
|
||||
end
|
||||
end
|
||||
|
||||
# Ignore following method
|
||||
desc "", "", :hide => true
|
||||
|
|
|
@ -70,12 +70,13 @@ module Middleman
|
|||
# @return [void]
|
||||
def bootup
|
||||
env = (@options[:environment] || "development").to_sym
|
||||
is_logging = @options.has_key?(:debug) && (@options[:debug] == "true")
|
||||
is_logging = @options.has_key?(:debug) && @options[:debug]
|
||||
|
||||
app = ::Middleman.server.inst do
|
||||
set :environment, env
|
||||
set :logging, is_logging
|
||||
end
|
||||
|
||||
$stderr.puts "Is logging?: #{is_logging}"
|
||||
app_rack = app.class.to_rack_app
|
||||
|
||||
opts = @options.dup
|
||||
|
|
Loading…
Reference in a new issue