From fdfb9c4c6fda97f213320005abff731f79ef822b Mon Sep 17 00:00:00 2001 From: Jade Dominguez Date: Wed, 1 Feb 2012 17:26:01 -0800 Subject: [PATCH] Fix prompt complaining that directories already exist When installing from a theme package we create an array of all files to be mirrored. We need to omit directories from this array since directories are recursively created for a given file. This needlessly raised 'directory already exist' errors which was annoying. - Also make error output friendlier --- Rakefile | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/Rakefile b/Rakefile index fe7a9d1..de6e2a9 100644 --- a/Rakefile +++ b/Rakefile @@ -134,6 +134,9 @@ namespace :theme do page.puts "{% include themes/#{theme_name}/#{File.basename(filename)} %}" end end + + puts "=> Theme successfully switched!" + puts "=> Reload your web-page to check it out =)" end # task :switch # Public: Install a theme using the theme packager. @@ -160,16 +163,26 @@ namespace :theme do packaged_theme_path = JB::Path.build(:theme_packages, :node => name) - abort("rake aborted: name cannot be blank") if name.empty? - abort("rake aborted: '#{packaged_theme_path}' directory not found.") unless FileTest.directory?(packaged_theme_path) + abort("rake aborted! + => ERROR: 'name' cannot be blank") if name.empty? + abort("rake aborted! + => ERROR: '#{packaged_theme_path}' directory not found. + => Installable themes can be added via git. You can find some here: http://github.com/jekyllbootstrap + => To download+install run: `rake theme:install git='[PUBLIC-CLONE-URL]'` + => example : rake theme:install git='git@github.com:jekyllbootstrap/theme-the-program.git' + ") unless FileTest.directory?(packaged_theme_path) manifest = verify_manifest(packaged_theme_path) # Get relative paths to packaged theme files + # Exclude directories as they'll be recursively created. Exclude meta-data files. packaged_theme_files = [] - FileUtils.cd(packaged_theme_path) { packaged_theme_files += Dir["**/*.*"] } - # Don't install metadata files. - packaged_theme_files.delete_if { |f| f =~ /^(manifest|readme|packager)/i } + FileUtils.cd(packaged_theme_path) { + Dir.glob("**/*.*") { |f| + next if ( FileTest.directory?(f) || f =~ /^(manifest|readme|packager)/i ) + packaged_theme_files << f + } + } # Mirror each file into the framework making sure to prompt if already exists. packaged_theme_files.each do |filename|