From 996170a4ade4f72df2efb6ee2e75edaab669809f Mon Sep 17 00:00:00 2001 From: Samy Pesse Date: Tue, 7 Jun 2016 00:48:47 +0200 Subject: [PATCH] ConfigModifier.removePlugin should toggle off if default --- lib/browser.js | 4 ++-- lib/modifiers/config/removePlugin.js | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/browser.js b/lib/browser.js index bb84044f7..ce56b59e0 100644 --- a/lib/browser.js +++ b/lib/browser.js @@ -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'), diff --git a/lib/modifiers/config/removePlugin.js b/lib/modifiers/config/removePlugin.js index 70ec3b1eb..123be0b6c 100644 --- a/lib/modifiers/config/removePlugin.js +++ b/lib/modifiers/config/removePlugin.js @@ -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; });