create output dirs before writing files
This commit is contained in:
parent
367437fec5
commit
feb22ad147
@ -11,6 +11,7 @@
|
|||||||
#/ --help Show this help message
|
#/ --help Show this help message
|
||||||
|
|
||||||
require 'optparse'
|
require 'optparse'
|
||||||
|
require 'fileutils'
|
||||||
|
|
||||||
# Write usage message to stdout and exit.
|
# Write usage message to stdout and exit.
|
||||||
def usage(stream=$stderr, status=1)
|
def usage(stream=$stderr, status=1)
|
||||||
@ -77,13 +78,11 @@ rescue LoadError
|
|||||||
raise
|
raise
|
||||||
end
|
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.
|
# Run each file through Rocco and write output.
|
||||||
sources.each do |filename|
|
sources.each do |filename|
|
||||||
rocco = Rocco.new(filename, sources, options)
|
rocco = Rocco.new(filename, sources, options)
|
||||||
dest = File.join(output_dir, filename.split('.')[0..-2].join('.') + '.html')
|
dest = File.join(output_dir, filename.split('.')[0..-2].join('.') + '.html')
|
||||||
puts "rocco: #{filename} -> #{dest}"
|
puts "rocco: #{filename} -> #{dest}"
|
||||||
|
FileUtils.mkdir_p File.dirname(dest)
|
||||||
File.open(dest, 'wb') { |fd| fd.write(rocco.to_html) }
|
File.open(dest, 'wb') { |fd| fd.write(rocco.to_html) }
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user