add middleman.rb option
This commit is contained in:
parent
0f785a448a
commit
e886eeaa3e
|
@ -1,6 +1,7 @@
|
|||
master
|
||||
===
|
||||
|
||||
* Add the option of naming `config.rb` as `middleman.rb`.
|
||||
* Builder extracted from Thor. `after_build` hook now passes an instance of a Builder instead of the Thor CLI.
|
||||
* New FileWatcher API.
|
||||
* Remove the `partials_dir` setting. Partials should live next to content, or be addressed with absolute paths.
|
||||
|
|
|
@ -25,7 +25,7 @@ module Middleman::Cli
|
|||
def init(target='.')
|
||||
require 'tmpdir'
|
||||
|
||||
repo = if shortname?(options[:template])
|
||||
repo_path, repo_branch = if shortname?(options[:template])
|
||||
require 'open-uri'
|
||||
require 'json'
|
||||
|
||||
|
@ -35,17 +35,21 @@ module Middleman::Cli
|
|||
begin
|
||||
data = ::JSON.parse(uri.read)
|
||||
data['links']['github']
|
||||
data['links']['github'].split('#')
|
||||
rescue ::OpenURI::HTTPError
|
||||
puts "Template `#{options[:template]}` not found in Middleman Directory."
|
||||
puts 'Did you mean to use a full `user/repo` path?'
|
||||
exit
|
||||
end
|
||||
else
|
||||
repository_path(options[:template])
|
||||
repo_name, repo_branch = options[:template].split('#')
|
||||
[repository_path(repo_name), repo_branch]
|
||||
end
|
||||
|
||||
Dir.mktmpdir do |dir|
|
||||
run("git clone #{repo} #{dir}")
|
||||
cmd = repo_branch ? "clone -b #{repo_branch}" : 'clone'
|
||||
|
||||
run("git #{cmd} #{repo_path} #{dir}")
|
||||
|
||||
source_paths << dir
|
||||
|
||||
|
|
|
@ -256,10 +256,17 @@ module Middleman
|
|||
|
||||
def evaluate_configuration
|
||||
# Check for and evaluate local configuration in `config.rb`
|
||||
local_config = File.join(root, 'config.rb')
|
||||
if File.exist? local_config
|
||||
logger.debug '== Reading: Local config'
|
||||
config_context.instance_eval File.read(local_config), local_config, 1
|
||||
config_rb = File.join(root, 'config.rb')
|
||||
if File.exist? config_rb
|
||||
logger.debug '== Reading: Local config: config.rb'
|
||||
config_context.instance_eval File.read(config_rb), config_rb, 1
|
||||
else
|
||||
# Check for and evaluate local configuration in `middleman.rb`
|
||||
middleman_rb = File.join(root, 'middleman.rb')
|
||||
if File.exist? middleman_rb
|
||||
logger.debug '== Reading: Local middleman: middleman.rb'
|
||||
config_context.instance_eval File.read(middleman_rb), middleman_rb, 1
|
||||
end
|
||||
end
|
||||
|
||||
env_config = File.join(root, 'environments', "#{config[:environment]}.rb")
|
||||
|
|
Loading…
Reference in a new issue