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

/**
    Remove a plugin from a book's configuration

    @param {Book} book
    @param {String} plugin
    @return {Book}
*/
function removePlugin(book, pluginName) {
    var config = book.getConfig();
    var plugins = config.getValue('plugins', []);

    // Find index of this plugin
    var index = plugins.findIndex(function(plugin) {
        return plugin === pluginName;
    });

    plugins = plugins.delete(index);
    config = config.setValue('plugins', plugins);

    return book.setConfig(config);
}

module.exports = removePlugin;