From 027ca8d639ce26bae3a1e2a8aeb5a4387185c6fc Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Sun, 1 Apr 2018 23:17:33 +0100 Subject: [PATCH] Change plugin API WebpackModules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit getModule[…] returns a module (first = true) getModules[…] returns an array (first = false) --- client/src/modules/pluginapi.js | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/client/src/modules/pluginapi.js b/client/src/modules/pluginapi.js index 82681401..1b09342f 100644 --- a/client/src/modules/pluginapi.js +++ b/client/src/modules/pluginapi.js @@ -402,14 +402,23 @@ export default class PluginApi { getWebpackModuleByName(name, fallback) { return WebpackModules.getModuleByName(name, fallback); } - getWebpackModuleByRegex(regex, first = true) { - return WebpackModules.getModuleByRegex(regex, first); + getWebpackModuleByRegex(regex) { + return WebpackModules.getModuleByRegex(regex, true); } - getWebpackModuleByProperties(props, first = true) { - return WebpackModules.getModuleByProps(props, first); + getWebpackModulesByRegex(regex) { + return WebpackModules.getModuleByRegex(regex, false); } - getWebpackModuleByPrototypeFields(props, first = true) { - return WebpackModules.getModuleByPrototypes(props, first); + getWebpackModuleByProperties(...props) { + return WebpackModules.getModuleByProps(props, true); + } + getWebpackModuleByPrototypeFields(...props) { + return WebpackModules.getModuleByPrototypes(props, true); + } + getWebpackModulesByProperties(...props) { + return WebpackModules.getModuleByProps(props, false); + } + getWebpackModulesByPrototypeFields(...props) { + return WebpackModules.getModuleByPrototypes(props, false); } get WebpackModules() { return Object.defineProperty({ @@ -417,8 +426,11 @@ export default class PluginApi { getModuleByName: this.getWebpackModuleByName.bind(this), getModuleByDisplayName: this.getWebpackModuleByName.bind(this), getModuleByRegex: this.getWebpackModuleByRegex.bind(this), + getModulesByRegex: this.getWebpackModulesByRegex.bind(this), getModuleByProperties: this.getWebpackModuleByProperties.bind(this), - getModuleByPrototypeFields: this.getWebpackModuleByPrototypeFields.bind(this) + getModuleByPrototypeFields: this.getWebpackModuleByPrototypeFields.bind(this), + getModulesByProperties: this.getWebpackModulesByProperties.bind(this), + getModulesByPrototypeFields: this.getWebpackModulesByPrototypeFields.bind(this) }, 'require', { get: () => this.webpackRequire });