diff options
author | Samy Pesse <samypesse@gmail.com> | 2016-02-17 21:43:54 +0100 |
---|---|---|
committer | Samy Pesse <samypesse@gmail.com> | 2016-02-17 21:43:54 +0100 |
commit | 004ac8851622cb4583b5569ae3480344855a7880 (patch) | |
tree | a3f5ee57686b971e493403988504780ea18164e3 /lib/plugins/index.js | |
parent | 3d1eac234a1633f4822fd019464434124875b7b1 (diff) | |
download | gitbook-004ac8851622cb4583b5569ae3480344855a7880.zip gitbook-004ac8851622cb4583b5569ae3480344855a7880.tar.gz gitbook-004ac8851622cb4583b5569ae3480344855a7880.tar.bz2 |
Add method .hook to plugins
Diffstat (limited to 'lib/plugins/index.js')
-rw-r--r-- | lib/plugins/index.js | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/plugins/index.js b/lib/plugins/index.js index 6eb788b..343c569 100644 --- a/lib/plugins/index.js +++ b/lib/plugins/index.js @@ -95,7 +95,13 @@ PluginsManager.prototype.install = function() { return registry.install(that.book, plugin.name, plugin.version); }) .thenResolve(plugins.length); +}; +// Call a hook on all plugins to transform an input +PluginsManager.prototype.hook = function(name, input) { + return Promise.reduce(this.plugins, function(current, plugin) { + return plugin.hook(name, current); + }, input); }; module.exports = PluginsManager; |