Skip to content

Commit af53dd8

Browse files
authored
Update Jekyll server monkey-patch to mirror Core (#499)
* Mark the methods as `private` since #start_up_webrick is a private method in the upstream command class * From Jekyll 3.7 onwards, local variable `server` is an instance_variable in the overridden method upstream
1 parent ac28fcd commit af53dd8

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

lib/jekyll/commands/serve.rb

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,24 @@ module Jekyll
22
module Commands
33
class Serve < Command
44
class << self
5+
private
6+
57
def start_up_webrick(opts, destination)
68
@reload_reactor.start(opts) if opts["livereload"]
79

8-
server = WEBrick::HTTPServer.new(webrick_opts(opts)).tap { |o| o.unmount("") }
9-
server.mount(opts["baseurl"], Servlet, destination, file_handler_opts)
10+
@server = WEBrick::HTTPServer.new(webrick_opts(opts)).tap { |o| o.unmount("") }
11+
@server.mount(opts["baseurl"].to_s, Servlet, destination, file_handler_opts)
1012

11-
jekyll_admin_monkey_patch(server)
13+
jekyll_admin_monkey_patch
1214

13-
Jekyll.logger.info "Server address:", server_address(server, opts)
14-
launch_browser server, opts if opts["open_url"]
15-
boot_or_detach server, opts
15+
Jekyll.logger.info "Server address:", server_address(@server, opts)
16+
launch_browser @server, opts if opts["open_url"]
17+
boot_or_detach @server, opts
1618
end
1719

18-
def jekyll_admin_monkey_patch(server)
19-
server.mount "/admin", Rack::Handler::WEBrick, JekyllAdmin::StaticServer
20-
server.mount "/_api", Rack::Handler::WEBrick, JekyllAdmin::Server
20+
def jekyll_admin_monkey_patch
21+
@server.mount "/admin", Rack::Handler::WEBrick, JekyllAdmin::StaticServer
22+
@server.mount "/_api", Rack::Handler::WEBrick, JekyllAdmin::Server
2123
Jekyll.logger.info "JekyllAdmin mode:", ENV["RACK_ENV"] || "production"
2224
end
2325
end

0 commit comments

Comments
 (0)