mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-22 02:23:30 +00:00
Fix calcul of output format for ebook
This commit is contained in:
@@ -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"
|
||||
}));
|
||||
});
|
||||
|
||||
@@ -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(" ");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user