diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-01-31 17:01:50 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-01-31 17:01:50 +0100 |
commit | a24aa79dbf5be625ec3fdac50aca955c0b478fec (patch) | |
tree | c2f9c15ae7c703d8bb1e100198108369bafb7174 /lib/output.js | |
parent | 633de85180b1c968edc3e884821c3de668d23506 (diff) | |
download | gitbook-a24aa79dbf5be625ec3fdac50aca955c0b478fec.zip gitbook-a24aa79dbf5be625ec3fdac50aca955c0b478fec.tar.gz gitbook-a24aa79dbf5be625ec3fdac50aca955c0b478fec.tar.bz2 |
Add base for templating
Diffstat (limited to 'lib/output.js')
-rw-r--r-- | lib/output.js | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/output.js b/lib/output.js index 89233da..01610c6 100644 --- a/lib/output.js +++ b/lib/output.js @@ -11,20 +11,22 @@ function Output(book, type) { if (!generators[type]) throw new Error('Generator not found"' + type + '"'); this.book = book; + this.log = this.book.log; + this.type = type; this.plugins = new PluginsManager(book); this.generator = new generators[type](this, type); // Files to ignore in output this.ignore = Ignore(); - this.ignore.addPattern([ + this.ignore.addPattern(_.compact([ '.gitignore', '.ignore', '.bookignore', // The configuration file should not be copied in the output this.book.config.filename - ]); + ])); } @@ -36,16 +38,25 @@ Output.prototype.resolve = function(filename) { // Write a file/buffer to the output folder Output.prototype.writeFile = function(filename, buf) { filename = this.resolve(filename); - return Promise.nfcall(fs.writeFileSync, filename, buf); + return Promise.nfcall(fs.writeFile, filename, buf); }; // Start the generation, for a parsed book Output.prototype.generate = function() { var that = this; - var isMultilingual = this.isMultilingual(); + var isMultilingual = this.book.isMultilingual(); return Promise() + // Load all plugins + .then(function() { + that.log.info.ln('Loading and preparing plugins'); + + var plugins = _.pluck(that.book.config.get('plugins'), 'name'); + + return that.plugins.load(plugins); + }) + // Initialize the generation .then(function() { return that.generator.prepare(); |