diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-01-23 14:10:45 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-01-23 14:10:45 +0100 |
commit | df16f3d90dc79366dd5cb30a6a91aa480397833f (patch) | |
tree | 5fce1ebb6655615bd091babeda04714ea2e6a823 | |
parent | ccd2f6ecdc17f796ff434ed89e63df4e3bee8434 (diff) | |
download | gitbook-df16f3d90dc79366dd5cb30a6a91aa480397833f.zip gitbook-df16f3d90dc79366dd5cb30a6a91aa480397833f.tar.gz gitbook-df16f3d90dc79366dd5cb30a6a91aa480397833f.tar.bz2 |
Test ebook generation instead of pdf output
-rw-r--r-- | lib/generators/ebook.js | 6 | ||||
-rw-r--r-- | lib/generators/index.js | 1 | ||||
-rw-r--r-- | test/ebook.js | 15 | ||||
-rw-r--r-- | test/pdf.js | 15 |
4 files changed, 20 insertions, 17 deletions
diff --git a/lib/generators/ebook.js b/lib/generators/ebook.js index fa5dcbd..b173c19 100644 --- a/lib/generators/ebook.js +++ b/lib/generators/ebook.js @@ -12,10 +12,10 @@ var Generator = function(book, format) { BaseGenerator.apply(this, arguments); // eBook format - this.ebookFormat = format || "pdf"; + this.ebookFormat = format; // Styles to use - this.styles = ["ebook", this.ebookFormat]; + this.styles = _.compact(["ebook", this.ebookFormat]); }; util.inherits(Generator, BaseGenerator); @@ -47,6 +47,8 @@ Generator.prototype.finish = function() { return that.writeSummary(); }) .then(function() { + if (!that.ebookFormat) return Q(); + var d = Q.defer(); if (!that.options.cover && fs.existsSync(path.join(that.options.output, "cover.jpg"))) { diff --git a/lib/generators/index.js b/lib/generators/index.js index 9189196..e619188 100644 --- a/lib/generators/index.js +++ b/lib/generators/index.js @@ -4,6 +4,7 @@ var EbookGenerator = require("./ebook"); module.exports = { json: require("./json"), website: require("./website"), + ebook: EbookGenerator, pdf: _.partialRight(EbookGenerator, "pdf"), mobi: _.partialRight(EbookGenerator, "mobi"), epub: _.partialRight(EbookGenerator, "epub") diff --git a/test/ebook.js b/test/ebook.js new file mode 100644 index 0000000..e835a6e --- /dev/null +++ b/test/ebook.js @@ -0,0 +1,15 @@ +var path = require('path'); +var _ = require('lodash'); +var assert = require('assert'); + +var fs = require("fs"); +var fsUtil = require("../lib/utils/fs"); + + +describe('eBook Generator', function () { + it('should correctly generate ebook pages', function(done) { + testGeneration(books[1], "ebook", function(output) { + assert(fs.existsSync(path.join(output, "SUMMARY.html"))); + }, done); + }); +}); diff --git a/test/pdf.js b/test/pdf.js deleted file mode 100644 index 9b5cf42..0000000 --- a/test/pdf.js +++ /dev/null @@ -1,15 +0,0 @@ -var path = require('path'); -var _ = require('lodash'); -var assert = require('assert'); - -var fs = require("fs"); -var fsUtil = require("../lib/utils/fs"); - - -describe('PDF Generator', function () { - it('should correctly generate a pdf', function(done) { - testGeneration(books[1], "pdf", function(output) { - assert(fs.existsSync(path.join(output, "book.pdf"))); - }, done); - }); -}); |