diff options
author | Samy Pesse <samypesse@gmail.com> | 2016-04-26 15:23:28 +0200 |
---|---|---|
committer | Samy Pesse <samypesse@gmail.com> | 2016-04-26 15:23:28 +0200 |
commit | fa17f1671685a97e88c84fdba6a94744c54a09b8 (patch) | |
tree | 63083c0645a1f88bc7e96d891ef9ec9509d7680a /lib/cli/build.js | |
parent | ce99c8c7061eb9b4a2a5f4ff534d7fbeaf37cad0 (diff) | |
download | gitbook-fa17f1671685a97e88c84fdba6a94744c54a09b8.zip gitbook-fa17f1671685a97e88c84fdba6a94744c54a09b8.tar.gz gitbook-fa17f1671685a97e88c84fdba6a94744c54a09b8.tar.bz2 |
Add base for commands
Improve plugins installation
Diffstat (limited to 'lib/cli/build.js')
-rw-r--r-- | lib/cli/build.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/cli/build.js b/lib/cli/build.js new file mode 100644 index 0000000..49931bd --- /dev/null +++ b/lib/cli/build.js @@ -0,0 +1,30 @@ +var path = require('path'); + +var options = require('./options'); +var getBook = require('./getBook'); + +var Parse = require('../parse'); +var Output = require('../output'); + +module.exports = { + name: 'build [book] [output]', + description: 'build a book', + options: [ + options.log, + options.format + ], + exec: function(args, kwargs) { + var book = getBook(args, kwargs); + var Generator = Output.getGenerator(kwargs.format); + + return Parse.parseBook(book) + .then(function(resultBook) { + var defaultOutputRoot = path.join(resultBook.getRoot(), '_book'); + var outputFolder = args[1]? path.resolve(process.cwd(), args[1]) : defaultOutputRoot; + + return Output.generate(Generator, resultBook, { + root: outputFolder + }); + }); + } +}; |