diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-01-24 18:56:18 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-01-24 18:56:18 +0100 |
commit | b4dc31e82bc7fc73e6283d433b0a7d70ddd5d5ba (patch) | |
tree | 7a7da9fa5a2a6b600ef8f161270595ad668624d5 /lib/index.js | |
parent | 1583ede3d7ae005f7bd399ab587ca9bddfe845ca (diff) | |
download | gitbook-b4dc31e82bc7fc73e6283d433b0a7d70ddd5d5ba.zip gitbook-b4dc31e82bc7fc73e6283d433b0a7d70ddd5d5ba.tar.gz gitbook-b4dc31e82bc7fc73e6283d433b0a7d70ddd5d5ba.tar.bz2 |
Add command to generate all ebooks
Diffstat (limited to 'lib/index.js')
-rw-r--r-- | lib/index.js | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/lib/index.js b/lib/index.js index 7d5fb25..0280e30 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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]; - - var book = new Book(input, _.extend({}, { - 'logLevel': Book.LOG_LEVELS[(kwargs.log).toUpperCase()] - })); - - return book.parse() - .then(function() { - return book.generateFile(output, { - ebookFormat: "pdf" + _.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()] + })); + + return book.parse() + .then(function() { + return book.generateFile(output, { + ebookFormat: ebookType + }); }); - }); - } - }, + } + }; + }), // Build and serve a book { @@ -183,5 +185,5 @@ module.exports = { }); } } - ] + ]) }; |