summaryrefslogtreecommitdiffstats
path: root/lib/book.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2015-10-13 15:14:26 +0200
committerSamy Pessé <samypesse@gmail.com>2015-10-13 15:14:26 +0200
commit8ba18cd587de8f073c9818acbdeaeaafe9a478c1 (patch)
treee83f6a9b6e4a37d2058d11653db73123a799aef0 /lib/book.js
parent4ae5b2e05001df9bdf8c5b64f8a82725e14d6414 (diff)
parent54c12fea89198ad6582529cf7bfd6c7ff6f92ed2 (diff)
downloadgitbook-8ba18cd587de8f073c9818acbdeaeaafe9a478c1.zip
gitbook-8ba18cd587de8f073c9818acbdeaeaafe9a478c1.tar.gz
gitbook-8ba18cd587de8f073c9818acbdeaeaafe9a478c1.tar.bz2
Merge pull request #979 from GitbookIO/feature/plugins_config
Improvements for plugin configurations
Diffstat (limited to 'lib/book.js')
-rw-r--r--lib/book.js17
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;