Browse code

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.

masukomi authored on 24/08/2011 at 02:45:29
Showing 1 changed files
... ...
@@ -37,6 +37,7 @@
37 37
 # Modified for Octopress by John W. Long
38 38
 #
39 39
 require 'rexml/document'
40
+require 'fileutils'
40 41
 
41 42
 module Jekyll
42 43
 
... ...
@@ -122,6 +123,9 @@ module Jekyll
122 122
       sitemap.add_element(urlset)
123 123
 
124 124
       # File I/O: create sitemap.xml file and write out pretty-printed XML
125
+      unless File.exists?(site.dest)
126
+        FileUtils.mkdir_p(site.dest)
127
+      end
125 128
       file = File.new(File.join(site.dest, SITEMAP_FILE_NAME), "w")
126 129
       formatter = REXML::Formatters::Pretty.new(4)
127 130
       formatter.compact = true