mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-20 17:43:24 +00:00
Test ebook generation instead of pdf output
This commit is contained in:
@@ -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"))) {
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
-15
@@ -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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user