diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/book.js | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/book.js b/lib/book.js index 064b9fc..96ceb06 100644 --- a/lib/book.js +++ b/lib/book.js @@ -117,7 +117,7 @@ Book.prototype.parse = function() { path.join(that.root, lang.path), _.merge({}, that.context, { config: _.extend({}, that.options, { - 'output': path.join(that.options.output, lang.path), + 'output': path.join(that.options.output, lang.lang), 'language': lang.lang }) }), @@ -185,8 +185,6 @@ Book.prototype.generate = function(generator) { return generator.prepare(); }) - - // Generate content .then(function() { if (that.isMultilingual()) { @@ -280,9 +278,7 @@ Book.prototype.generateFile = function(output, options) { return fs.tmp.dir() .then(function(tmpDir) { - book.config.extend({ - output: tmpDir - }); + book.setOutput(tmpDir); return book.generate(options.ebookFormat) .then(function(_options) { @@ -295,7 +291,7 @@ Book.prototype.generateFile = function(output, options) { _tmpDir = path.join(_tmpDir, lang); } - book.log.info.ln("copy ebook to", _outputFile); + book.log.debug.ln("copy ebook to", _outputFile); return fs.copy( path.join(_tmpDir, "index."+options.ebookFormat), _outputFile @@ -692,6 +688,16 @@ Book.prototype._defaultsStructure = function(filename) { that.langsFile = that.langsFile || that.config.getStructure("langs")+extension; } +// Change output path +Book.prototype.setOutput = function(p) { + var that = this; + this.options.output = path.resolve(p); + + _.each(this.books, function(book) { + book.setOutput(path.join(that.options.output, book.options.language)); + }); +}; + // Init and return a book Book.init = function(root) { |