Fix calcul of output format for ebook

This commit is contained in:
Samy Pessé
2014-06-02 18:16:44 +02:00
parent a91245d575
commit 7dfcd102dd
2 changed files with 2 additions and 10 deletions
-3
View File
@@ -83,10 +83,7 @@ build.command(prog.command('serve [source_dir]'))
build.commandEbook(prog.command('ebook [source_dir]'))
.description('Build a gitbook as a eBook (format detected according to the extension)')
.action(function(dir, options) {
var ext = options.output ? path.extname(options.output) : "epub";
build.file(dir, _.extend(options, {
extension: ext,
format: "ebook"
}));
});
+2 -7
View File
@@ -15,11 +15,6 @@ var stringUtils = require("../../utils/string");
*/
var Generator = function() {
BaseGenerator.apply(this, arguments);
// Options for eBook generation
this.options = _.defaults(this.options, {
extension: "epub"
});
};
util.inherits(Generator, BaseGenerator);
@@ -29,7 +24,7 @@ Generator.prototype.finish = function() {
return BaseGenerator.prototype.finish.apply(this)
.then(function() {
var d = Q.defer();
var format = that.options.extension || path.extname(that.options.output);
var format = that.options.extension || path.extname(that.options.output).replace("\.", "") || "pdf";
if (!that.options.cover && fs.existsSync(path.join(that.options.output, "cover.jpg"))) {
that.options.cover = path.join(that.options.output, "cover.jpg");
@@ -72,7 +67,7 @@ Generator.prototype.finish = function() {
var command = [
"ebook-convert",
path.join(that.options.output, "index.html"),
path.join(that.options.output, "index."+that.options.extension),
path.join(that.options.output, "index."+format),
stringUtils.optionsToShellArgs(_options)
].join(" ");