Skip to content

Commit fdfb9c4

Browse files
committed
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
1 parent 533d840 commit fdfb9c4

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

Rakefile

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ namespace :theme do
134134
page.puts "{% include themes/#{theme_name}/#{File.basename(filename)} %}"
135135
end
136136
end
137+
138+
puts "=> Theme successfully switched!"
139+
puts "=> Reload your web-page to check it out =)"
137140
end # task :switch
138141

139142
# Public: Install a theme using the theme packager.
@@ -160,16 +163,26 @@ namespace :theme do
160163

161164
packaged_theme_path = JB::Path.build(:theme_packages, :node => name)
162165

163-
abort("rake aborted: name cannot be blank") if name.empty?
164-
abort("rake aborted: '#{packaged_theme_path}' directory not found.") unless FileTest.directory?(packaged_theme_path)
166+
abort("rake aborted!
167+
=> ERROR: 'name' cannot be blank") if name.empty?
168+
abort("rake aborted!
169+
=> ERROR: '#{packaged_theme_path}' directory not found.
170+
=> Installable themes can be added via git. You can find some here: http://github.com/jekyllbootstrap
171+
=> To download+install run: `rake theme:install git='[PUBLIC-CLONE-URL]'`
172+
=> example : rake theme:install git='git@github.com:jekyllbootstrap/theme-the-program.git'
173+
") unless FileTest.directory?(packaged_theme_path)
165174

166175
manifest = verify_manifest(packaged_theme_path)
167176

168177
# Get relative paths to packaged theme files
178+
# Exclude directories as they'll be recursively created. Exclude meta-data files.
169179
packaged_theme_files = []
170-
FileUtils.cd(packaged_theme_path) { packaged_theme_files += Dir["**/*.*"] }
171-
# Don't install metadata files.
172-
packaged_theme_files.delete_if { |f| f =~ /^(manifest|readme|packager)/i }
180+
FileUtils.cd(packaged_theme_path) {
181+
Dir.glob("**/*.*") { |f|
182+
next if ( FileTest.directory?(f) || f =~ /^(manifest|readme|packager)/i )
183+
packaged_theme_files << f
184+
}
185+
}
173186

174187
# Mirror each file into the framework making sure to prompt if already exists.
175188
packaged_theme_files.each do |filename|

0 commit comments

Comments
 (0)