ConfigModifier.removePlugin should toggle off if default

This commit is contained in:
Samy Pesse
2016-06-07 00:48:47 +02:00
parent aa66a4f928
commit 996170a4ad
2 changed files with 14 additions and 2 deletions
+2 -2
View File
@@ -12,8 +12,8 @@ module.exports = {
PluginDependency: require('./models/pluginDependency'),
// Modifiers
SummaryModifier: Modifiers.Summary,
ConfigModifier: Modifiers.Config,
SummaryModifier: Modifiers.Summary,
ConfigModifier: Modifiers.Config,
// Constants
CONFIG_FILES: require('./constants/configFiles.js'),
+12
View File
@@ -1,3 +1,5 @@
var DEFAULT_PLUGINS = require('../../constants/defaultPlugins');
var togglePlugin = require('./togglePlugin');
/**
* Remove a plugin from a book's configuration
@@ -8,6 +10,16 @@
function removePlugin(config, pluginName) {
var deps = config.getPluginDependencies();
var isDefault = DEFAULT_PLUGINS.find(function(dep) {
return dep.getName() === pluginName;
});
// For default plugin, we have to disable it instead of removing from the list
if (isDefault) {
return togglePlugin(config, pluginName, false);
}
// Remove the dependency from the list
deps = deps.filter(function(dep) {
return dep.getName() === pluginName;
});