Update Jekyll.configuration to convert symbol keys
Because Commander uses symbol keys in the options hash and I don't want to go
back backport every hash string key to symbols in Jekyll. ⭐
This commit is contained in:
parent
5b2e95b443
commit
bd1c8fe760
|
@ -28,7 +28,7 @@ command :build do |c|
|
||||||
c.description = 'Build your site with the option of auto-renegeration'
|
c.description = 'Build your site with the option of auto-renegeration'
|
||||||
c.option '-w', '--watch', 'Watch for changes and rebuild'
|
c.option '-w', '--watch', 'Watch for changes and rebuild'
|
||||||
c.action do |args, options|
|
c.action do |args, options|
|
||||||
Jekyll::BuildCommand.process(options)
|
Jekyll::BuildCommand.process(options.__hash__)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ command :serve do |c|
|
||||||
:baseurl => '/',
|
:baseurl => '/',
|
||||||
:serving => true
|
:serving => true
|
||||||
|
|
||||||
Jekyll::BuildCommand.process(options)
|
Jekyll::BuildCommand.process(options.__hash__)
|
||||||
Jekyll::ServeCommand.process(options)
|
Jekyll::ServeCommand.process(options.__hash__)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -123,6 +123,9 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# Returns the final configuration Hash.
|
# Returns the final configuration Hash.
|
||||||
def self.configuration(override)
|
def self.configuration(override)
|
||||||
|
# Convert any symbol keys to strings and remove the old key/values
|
||||||
|
override.keys.each { |k| override[k.to_s] = override.delete(k) }
|
||||||
|
|
||||||
# _config.yml may override default source location, but until
|
# _config.yml may override default source location, but until
|
||||||
# then, we need to know where to look for _config.yml
|
# then, we need to know where to look for _config.yml
|
||||||
source = override['source'] || Jekyll::DEFAULTS['source']
|
source = override['source'] || Jekyll::DEFAULTS['source']
|
||||||
|
|
|
@ -2,21 +2,16 @@ module Jekyll
|
||||||
|
|
||||||
class BuildCommand < Command
|
class BuildCommand < Command
|
||||||
def self.process(options)
|
def self.process(options)
|
||||||
opts = {}
|
options = Jekyll.configuration(options)
|
||||||
options.__hash__.map do |k,v|
|
site = Jekyll::Site.new(options)
|
||||||
opts[k.to_s] = v
|
|
||||||
end
|
|
||||||
|
|
||||||
opts = Jekyll.configuration(opts)
|
source = options['source']
|
||||||
site = Jekyll::Site.new(opts)
|
destination = options['destination']
|
||||||
|
|
||||||
source = opts['source']
|
if options['watch']
|
||||||
destination = opts['destination']
|
self.watch(site, options)
|
||||||
|
|
||||||
if opts['watch']
|
|
||||||
self.watch(site, opts)
|
|
||||||
else
|
else
|
||||||
self.build(site, opts)
|
self.build(site, options)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Jekyll
|
||||||
require 'webrick'
|
require 'webrick'
|
||||||
include WEBrick
|
include WEBrick
|
||||||
|
|
||||||
destination = options.destination
|
destination = options['destination']
|
||||||
|
|
||||||
FileUtils.mkdir_p(destination)
|
FileUtils.mkdir_p(destination)
|
||||||
|
|
||||||
|
@ -13,12 +13,12 @@ module Jekyll
|
||||||
mime_types.store 'js', 'application/javascript'
|
mime_types.store 'js', 'application/javascript'
|
||||||
|
|
||||||
s = HTTPServer.new(
|
s = HTTPServer.new(
|
||||||
:Port => options.port,
|
:Port => options['port'],
|
||||||
:BindAddress => options.host,
|
:BindAddress => options['host'],
|
||||||
:MimeTypes => mime_types
|
:MimeTypes => mime_types
|
||||||
)
|
)
|
||||||
|
|
||||||
s.mount(options.baseurl, HTTPServlet::FileHandler, destination)
|
s.mount(options['baseurl'], HTTPServlet::FileHandler, destination)
|
||||||
t = Thread.new { s.start }
|
t = Thread.new { s.start }
|
||||||
trap("INT") { s.shutdown }
|
trap("INT") { s.shutdown }
|
||||||
t.join()
|
t.join()
|
||||||
|
|
Loading…
Reference in New Issue