fix
This commit is contained in:
32
book/node_modules/honkit/lib/modifiers/config/togglePlugin.js
generated
vendored
Normal file
32
book/node_modules/honkit/lib/modifiers/config/togglePlugin.js
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const pluginDependency_1 = __importDefault(require("../../models/pluginDependency"));
|
||||
const hasPlugin_1 = __importDefault(require("./hasPlugin"));
|
||||
const isDefaultPlugin_1 = __importDefault(require("./isDefaultPlugin"));
|
||||
/**
|
||||
* Enable/disable a plugin dependency
|
||||
* @param {Config} config
|
||||
* @param {string} pluginName
|
||||
* @param {boolean} state (optional)
|
||||
* @return {Config}
|
||||
*/
|
||||
function togglePlugin(config, pluginName, state) {
|
||||
let deps = config.getPluginDependencies();
|
||||
// For default plugin, we should ensure it's listed first
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
if ((0, isDefaultPlugin_1.default)(pluginName) && !(0, hasPlugin_1.default)(deps, pluginName)) {
|
||||
// @ts-expect-error ts-migrate(2339) FIXME: Property 'create' does not exist on type 'Class'.
|
||||
deps = deps.push(pluginDependency_1.default.create(pluginName));
|
||||
}
|
||||
deps = deps.map((dep) => {
|
||||
if (dep.getName() === pluginName) {
|
||||
return dep.toggle(state);
|
||||
}
|
||||
return dep;
|
||||
});
|
||||
return config.setPluginDependencies(deps);
|
||||
}
|
||||
exports.default = togglePlugin;
|
Reference in New Issue
Block a user