Skip to content

Commit

Permalink
fix epub build_path on debug
Browse files Browse the repository at this point in the history
same as pdfmake #556
  • Loading branch information
takahashim committed Apr 17, 2016
1 parent 4f5c891 commit 0ccffe7
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lib/review/epubmaker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ def load_yaml(yamlfile)
@params.maker = "epubmaker"
end

def build_path
if @params["debug"]
path = File.expand_path("#{@params["bookname"]}-epub", Dir.pwd)
if File.exist?(path)
FileUtils.rm_rf(path, :secure => true)
end
Dir.mkdir(path)
return path
else
return Dir.mktmpdir("#{@params["bookname"]}-epub-")
end
end

def produce(yamlfile, bookname=nil)
load_yaml(yamlfile)
I18n.setup(@params["language"])
Expand All @@ -52,7 +65,7 @@ def produce(yamlfile, bookname=nil)
FileUtils.rm_f("#{bookname}.epub")
FileUtils.rm_rf(booktmpname) if @params["debug"]

basetmpdir = Dir.mktmpdir("#{bookname}-", Dir.pwd)
basetmpdir = build_path()
begin
log("Created first temporary directory as #{basetmpdir}.")

Expand Down Expand Up @@ -92,7 +105,7 @@ def produce(yamlfile, bookname=nil)

epubtmpdir = nil
if @params["debug"].present?
epubtmpdir = "#{Dir.pwd}/#{booktmpname}"
epubtmpdir = "#{basetmpdir}/#{booktmpname}"
Dir.mkdir(epubtmpdir)
end
log("Call ePUB producer.")
Expand Down

0 comments on commit 0ccffe7

Please sign in to comment.