sitemap_generator dies if public dir doesn't exist yet

this tests for the presence of the public dir and creates
it if needed. This situation can arise in a new install.
This commit is contained in:
masukomi 2011-08-23 22:45:29 -04:00 committed by Brandon Mathis
parent 35a158dd14
commit e20e68139c

View File

@ -37,6 +37,7 @@
# Modified for Octopress by John W. Long # Modified for Octopress by John W. Long
# #
require 'rexml/document' require 'rexml/document'
require 'fileutils'
module Jekyll module Jekyll
@ -122,6 +123,9 @@ module Jekyll
sitemap.add_element(urlset) sitemap.add_element(urlset)
# File I/O: create sitemap.xml file and write out pretty-printed XML # File I/O: create sitemap.xml file and write out pretty-printed XML
unless File.exists?(site.dest)
FileUtils.mkdir_p(site.dest)
end
file = File.new(File.join(site.dest, SITEMAP_FILE_NAME), "w") file = File.new(File.join(site.dest, SITEMAP_FILE_NAME), "w")
formatter = REXML::Formatters::Pretty.new(4) formatter = REXML::Formatters::Pretty.new(4)
formatter.compact = true formatter.compact = true