diff --git a/bin/rocco b/bin/rocco index 1d0e219..5ed745c 100755 --- a/bin/rocco +++ b/bin/rocco @@ -11,6 +11,7 @@ #/ --help Show this help message require 'optparse' +require 'fileutils' # Write usage message to stdout and exit. def usage(stream=$stderr, status=1) @@ -77,13 +78,11 @@ rescue LoadError raise end -# Create the output directory if it doesn't already exist. -Dir.mkdir output_dir if !File.directory?(output_dir) - # Run each file through Rocco and write output. sources.each do |filename| rocco = Rocco.new(filename, sources, options) dest = File.join(output_dir, filename.split('.')[0..-2].join('.') + '.html') puts "rocco: #{filename} -> #{dest}" + FileUtils.mkdir_p File.dirname(dest) File.open(dest, 'wb') { |fd| fd.write(rocco.to_html) } end