summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-02-17 12:02:58 +0100
committerSamy Pessé <samypesse@gmail.com>2016-02-17 12:02:58 +0100
commite2c21051aa6a42f13208297d08688b99d45ddb27 (patch)
tree298db652d074de5aee362da73f3878a58f727676
parent7c575e1b43d75a22bad035a3ce62110572dff1c9 (diff)
downloadgitbook-e2c21051aa6a42f13208297d08688b99d45ddb27.zip
gitbook-e2c21051aa6a42f13208297d08688b99d45ddb27.tar.gz
gitbook-e2c21051aa6a42f13208297d08688b99d45ddb27.tar.bz2
Add method install to plugins manager
-rw-r--r--lib/output/base.js6
-rw-r--r--lib/plugins/index.js25
2 files changed, 25 insertions, 6 deletions
diff --git a/lib/output/base.js b/lib/output/base.js
index 2b9cdc7..02a69b1 100644
--- a/lib/output/base.js
+++ b/lib/output/base.js
@@ -50,11 +50,7 @@ Output.prototype.generate = function() {
// 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);
+ return that.plugins.loadAll();
})
// Initialize the generation
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;