diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-10-12 10:43:14 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-10-12 10:43:14 +0200 |
commit | 9ba1075f4866131f790388ebabc1b8636926dd7f (patch) | |
tree | 38ba7f7bb414fc8c8589901c90d4863b800614c6 /lib/book.js | |
parent | 4ae5b2e05001df9bdf8c5b64f8a82725e14d6414 (diff) | |
download | gitbook-9ba1075f4866131f790388ebabc1b8636926dd7f.zip gitbook-9ba1075f4866131f790388ebabc1b8636926dd7f.tar.gz gitbook-9ba1075f4866131f790388ebabc1b8636926dd7f.tar.bz2 |
Add hook "config" to transform configuration before generation
Diffstat (limited to 'lib/book.js')
-rw-r--r-- | lib/book.js | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/book.js b/lib/book.js index 72f0ec2..39d4719 100644 --- a/lib/book.js +++ b/lib/book.js @@ -178,6 +178,14 @@ Book.prototype.generate = function(generator) { return generator.prepare(); }) + // Transform configuration + .then(function() { + return that.callHook('config', that.config.dump()) + .then(function(newConfig) { + that.config.replace(newConfig); + }); + }) + // Generate content .then(function() { if (that.isMultilingual()) { @@ -238,13 +246,13 @@ Book.prototype.generate = function(generator) { // Finish generation .then(function() { - return generator.callHook('finish:before'); + return that.callHook('finish:before'); }) .then(function() { return generator.finish(); }) .then(function() { - return generator.callHook('finish'); + return that.callHook('finish'); }) .then(function() { that.log.info.ln('generation is finished'); @@ -793,4 +801,9 @@ Book.prototype.normError = function(err, opts, defs) { return err; }; +// Call a hook in plugins +Book.prototype.callHook = function(name, data) { + return this.plugins.hook(name, data); +}; + module.exports= Book; |