From 640c87c13a4322aae55f674a51bfbcb8e901bcd3 Mon Sep 17 00:00:00 2001 From: Alessandro Tagliapietra Date: Thu, 12 Feb 2015 15:40:54 +0100 Subject: [PATCH] Clone template from full repository urls --- middleman-cli/lib/middleman-cli/init.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/middleman-cli/lib/middleman-cli/init.rb b/middleman-cli/lib/middleman-cli/init.rb index 7e9f7810..ae50a408 100644 --- a/middleman-cli/lib/middleman-cli/init.rb +++ b/middleman-cli/lib/middleman-cli/init.rb @@ -53,6 +53,11 @@ module Middleman::Cli 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 thorfile = File.join(dir, 'Thorfile') @@ -68,18 +73,18 @@ module Middleman::Cli run('bundle install') unless ENV['TEST'] || options[:'skip-bundle'] end ensure - FileUtils.remove_entry(dir) + FileUtils.remove_entry(dir) if File.directory?(dir) end end protected def shortname?(repo) - repo.split('/').length != 2 + repo.split('/').length == 1 end def repository_path(repo) - "git://github.com/#{repo}.git" + repo.include?('://') ? repo : "git://github.com/#{repo}.git" end # Add to CLI