Add command to generate all ebooks

This commit is contained in:
Samy Pessé
2015-01-24 18:56:18 +01:00
parent 1583ede3d7
commit b4dc31e82b
+23 -21
View File
@@ -26,7 +26,7 @@ var FORMAT_OPTION = {
module.exports = {
Book: Book,
commands: [
commands: _.flatten([
// Build command that simply build a book into an output folder
{
name: "build [book] [output]",
@@ -54,28 +54,30 @@ module.exports = {
},
// Build an ebook and output it
{
name: "pdf [book] [output]",
description: "build a book to pdf",
options: [
LOG_OPTION
],
exec: function(args, kwargs) {
var input = args[0] || process.cwd();
var output = args[1];
_.map(["pdf", "epub", "mobi"], function(ebookType) {
return {
name: ebookType+" [book] [output]",
description: "build a book to "+ebookType,
options: [
LOG_OPTION
],
exec: function(args, kwargs) {
var input = args[0] || process.cwd();
var output = args[1];
var book = new Book(input, _.extend({}, {
'logLevel': Book.LOG_LEVELS[(kwargs.log).toUpperCase()]
}));
var book = new Book(input, _.extend({}, {
'logLevel': Book.LOG_LEVELS[(kwargs.log).toUpperCase()]
}));
return book.parse()
.then(function() {
return book.generateFile(output, {
ebookFormat: "pdf"
return book.parse()
.then(function() {
return book.generateFile(output, {
ebookFormat: ebookType
});
});
});
}
},
}
};
}),
// Build and serve a book
{
@@ -183,5 +185,5 @@ module.exports = {
});
}
}
]
])
};