Clone template from full repository urls

This commit is contained in:
Alessandro Tagliapietra 2015-02-12 15:40:54 +01:00
parent 986b9fcf51
commit 640c87c13a

View file

@ -53,6 +53,11 @@ module Middleman::Cli
run("git clone --depth 1 #{branch_cmd}#{repo_path} #{dir}") run("git clone --depth 1 #{branch_cmd}#{repo_path} #{dir}")
unless File.directory?(dir)
say 'Git clone failed, maybe the url is invalid or you don\'t have the permissions?', :red
exit
end
inside(target) do inside(target) do
thorfile = File.join(dir, 'Thorfile') thorfile = File.join(dir, 'Thorfile')
@ -68,18 +73,18 @@ module Middleman::Cli
run('bundle install') unless ENV['TEST'] || options[:'skip-bundle'] run('bundle install') unless ENV['TEST'] || options[:'skip-bundle']
end end
ensure ensure
FileUtils.remove_entry(dir) FileUtils.remove_entry(dir) if File.directory?(dir)
end end
end end
protected protected
def shortname?(repo) def shortname?(repo)
repo.split('/').length != 2 repo.split('/').length == 1
end end
def repository_path(repo) def repository_path(repo)
"git://github.com/#{repo}.git" repo.include?('://') ? repo : "git://github.com/#{repo}.git"
end end
# Add to CLI # Add to CLI