mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-28 04:58:52 +00:00
Fix parsing of plugins list
This commit is contained in:
+3
-3
@@ -138,9 +138,9 @@ Book.prototype.parsePlugins = function() {
|
||||
var failed = [];
|
||||
|
||||
// Load plugins
|
||||
that.plugins = _.map(that.options.plugins, function(name) {
|
||||
var plugin = new Plugin(that, name);
|
||||
if (!plugin.isValid()) failed.push(name);
|
||||
that.plugins = _.map(that.options.plugins, function(plugin) {
|
||||
var plugin = new Plugin(that, plugin.name);
|
||||
if (!plugin.isValid()) failed.push(plugin.name);
|
||||
return plugin;
|
||||
});
|
||||
|
||||
|
||||
@@ -13,8 +13,13 @@ function normalizePluginsList(plugins) {
|
||||
// Normalize list to an array
|
||||
plugins = _.isString(plugins) ? plugins.split(",") : (plugins || []);
|
||||
|
||||
// Remove empty parts
|
||||
plugins = _.compact(plugins);
|
||||
|
||||
// Divide as {name, version} to handle format like "myplugin@1.0.0"
|
||||
plugins = _.map(plugins, function(plugin) {
|
||||
if (plugin.name) return plugin;
|
||||
|
||||
var parts = plugin.split("@");
|
||||
return {
|
||||
'name': parts[0],
|
||||
@@ -80,7 +85,7 @@ Configuration.prototype.load = function() {
|
||||
.then(function() {
|
||||
that.options.output = that.options.output || path.join(that.book.root, "_book");
|
||||
that.options.plugins = normalizePluginsList(that.options.plugins);
|
||||
that.options.defaultsPlugins = normalizePluginsList(that.options.defaultsPlugins);
|
||||
that.options.defaultsPlugins = normalizePluginsList(that.options.defaultsPlugins || "");
|
||||
that.options.plugins = _.union(that.options.plugins, that.options.defaultsPlugins);
|
||||
that.options.plugins = _.uniq(that.options.plugins, "name");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user