28 lines
1.1 KiB
JavaScript
28 lines
1.1 KiB
JavaScript
"use strict";
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const togglePlugin_1 = __importDefault(require("./togglePlugin"));
|
|
const isDefaultPlugin_1 = __importDefault(require("./isDefaultPlugin"));
|
|
/**
|
|
* Remove a plugin from a book's configuration
|
|
* @param {Config} config
|
|
* @param {string} plugin
|
|
* @return {Config}
|
|
*/
|
|
function removePlugin(config, pluginName) {
|
|
let deps = config.getPluginDependencies();
|
|
// For default plugin, we have to disable it instead of removing from the list
|
|
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
|
if ((0, isDefaultPlugin_1.default)(pluginName)) {
|
|
return (0, togglePlugin_1.default)(config, pluginName, false);
|
|
}
|
|
// Remove the dependency from the list
|
|
deps = deps.filterNot((dep) => {
|
|
return dep.getName() === pluginName;
|
|
});
|
|
return config.setPluginDependencies(deps);
|
|
}
|
|
exports.default = removePlugin;
|