mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-16 15:45:13 +00:00
24 lines
486 B
JavaScript
24 lines
486 B
JavaScript
|
|
/**
|
|
* 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;
|