add middleman.rb option
This commit is contained in:
parent
0f785a448a
commit
e886eeaa3e
3 changed files with 19 additions and 7 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue