mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-21 01:53:26 +00:00
Add command to generate all ebooks
This commit is contained in:
+23
-21
@@ -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 = {
|
||||
});
|
||||
}
|
||||
}
|
||||
]
|
||||
])
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user