summaryrefslogtreecommitdiffstats
path: root/lib/modifiers/config/removePlugin.js
diff options
context:
space:
mode:
authorSamy Pesse <samypesse@gmail.com>2016-06-07 00:48:47 +0200
committerSamy Pesse <samypesse@gmail.com>2016-06-07 00:48:47 +0200
commit996170a4ade4f72df2efb6ee2e75edaab669809f (patch)
tree50ce8da8b837e637a6cab3eef07e0fd329a991d0 /lib/modifiers/config/removePlugin.js
parentaa66a4f928122856370d6d8579b9fd3d15fcccad (diff)
downloadgitbook-996170a4ade4f72df2efb6ee2e75edaab669809f.zip
gitbook-996170a4ade4f72df2efb6ee2e75edaab669809f.tar.gz
gitbook-996170a4ade4f72df2efb6ee2e75edaab669809f.tar.bz2
ConfigModifier.removePlugin should toggle off if default
Diffstat (limited to 'lib/modifiers/config/removePlugin.js')
-rw-r--r--lib/modifiers/config/removePlugin.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/modifiers/config/removePlugin.js b/lib/modifiers/config/removePlugin.js
index 70ec3b1..123be0b 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;
});