summaryrefslogtreecommitdiffstats
path: root/lib/output.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/output.js')
-rw-r--r--lib/output.js19
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();