summaryrefslogtreecommitdiffstats
path: root/lib/modifiers/config/togglePlugin.js
blob: 0cc49326a45a73da430bedb518b64e50f08c2668 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

/**
 * Enable/disable a plugin dependency
 * @param {Config} config
 * @param {String} plugin
 * @param {Boolean} state (optional)
 * @return {Config}
 */
function togglePlugin(config, plugin, state) {
    var deps = config.getPluginDependencies();

    deps = deps.map(function(dep) {
        if (dep.getName() === plugin) {
            return dep.toggle(state);
        }

        return dep;
    });

    return config.setPluginDependencies(deps);
}

module.exports = togglePlugin;