summaryrefslogtreecommitdiffstats
path: root/lib/book.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2015-02-04 18:31:07 +0100
committerSamy Pessé <samypesse@gmail.com>2015-02-04 18:31:07 +0100
commitf71601e8d3c94601e377b86265436e5028ed3b4c (patch)
treee1bece94daa29d06baba48619cbf2f8f7a9a9a9b /lib/book.js
parent234a37726fe895f59f8fc0329ea4d1ebebe92d14 (diff)
downloadgitbook-f71601e8d3c94601e377b86265436e5028ed3b4c.zip
gitbook-f71601e8d3c94601e377b86265436e5028ed3b4c.tar.gz
gitbook-f71601e8d3c94601e377b86265436e5028ed3b4c.tar.bz2
Fix generation of multilingual books as ebook
Diffstat (limited to 'lib/book.js')
-rw-r--r--lib/book.js20
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) {