Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom config files from CLI #322

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/jekyll-admin/server/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,17 @@ def raw_configuration
configuration.read_config_file(configuration_path)
end

def custom_configs
Jekyll::Commands::Serve.custom_configs
end

# Returns the path to the *first* config file discovered
def configuration_path
sanitized_path configuration.config_files(overrides).first
if custom_configs
sanitized_path custom_configs.first
else
sanitized_path configuration.config_files(overrides).first
end
end

# The user's uploaded configuration for updates
Expand Down
15 changes: 15 additions & 0 deletions lib/jekyll/commands/serve.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@ module Jekyll
module Commands
class Serve < Command
class << self
def process(opts)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than monkey patching another method, can we pass the options hash to our existing monkeypatch?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find another way to bypass this deletion

@overrides = opts["config"] if opts["config"]

opts = configuration_from_options(opts)
destination = opts["destination"]
setup(destination)

start_up_webrick(opts, destination)
end

def custom_configs
return nil unless @overrides
@overrides
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be simplified to an attr_accessor?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was under the impression that when we define an attr_accessor, its called again via #initialize method

end

def start_up_webrick(opts, destination)
server = WEBrick::HTTPServer.new(webrick_opts(opts)).tap { |o| o.unmount("") }
server.mount(opts["baseurl"], Servlet, destination, file_handler_opts)
Expand Down