diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-02-17 12:02:58 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-02-17 12:02:58 +0100 |
commit | e2c21051aa6a42f13208297d08688b99d45ddb27 (patch) | |
tree | 298db652d074de5aee362da73f3878a58f727676 /lib/plugins | |
parent | 7c575e1b43d75a22bad035a3ce62110572dff1c9 (diff) | |
download | gitbook-e2c21051aa6a42f13208297d08688b99d45ddb27.zip gitbook-e2c21051aa6a42f13208297d08688b99d45ddb27.tar.gz gitbook-e2c21051aa6a42f13208297d08688b99d45ddb27.tar.bz2 |
Add method install to plugins manager
Diffstat (limited to 'lib/plugins')
-rw-r--r-- | lib/plugins/index.js | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/plugins/index.js b/lib/plugins/index.js index f26c63d..9642b4b 100644 --- a/lib/plugins/index.js +++ b/lib/plugins/index.js @@ -63,6 +63,14 @@ PluginsManager.prototype.load = function(name) { .then(this._setup); }; +// Load all plugins from the book's configuration +PluginsManager.prototype.loadAll = function() { + var plugins = _.pluck(this.book.config.get('plugins'), 'name'); + + this.log.info.ln('installing', plugins.length, 'plugins'); + return this.load(plugins); +}; + // Setup a plugin // Register its filter, blocks, etc PluginsManager.prototype._setup = function(plugin) { @@ -71,7 +79,22 @@ PluginsManager.prototype._setup = function(plugin) { // Install all plugins for the book PluginsManager.prototype.install = function() { - this.log.info.ln('installing 0 plugins'); + var plugins = _.filter(this.book.config.get('plugins'), { + isDefault: false + }); + + if (plugins.length == 0) { + this.log.info.ln('nothing to install!'); + return Promise(0); + } + + this.log.info.ln('installing', plugins.length, 'plugins'); + + return Promise.serie(plugins, function(plugin) { + return registry.install(plugin.name, plugin.version); + }) + .thenResolve(plugins.length); + }; module.exports = PluginsManager; |