import PluginDependency from "../../models/pluginDependency" ; import hasPlugin from "./hasPlugin" ; import isDefaultPlugin from "./isDefaultPlugin" ; param { Config } config param { string } pluginName param { boolean } state return { Config } function togglePlugin ( config , pluginName , state ) { let deps = config . getPluginDependencies ( ) ; if ( isDefaultPlugin ( pluginName ) && ! hasPlugin ( deps , pluginName ) ) { deps = deps . push ( PluginDependency . create ( pluginName ) ) ; } deps = deps . map ( ( dep ) => { if ( dep . getName ( ) === pluginName ) { return dep . toggle ( state ) ; } return dep ; } ) ; return config . setPluginDependencies ( deps ) ; } export default togglePlugin ;