File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -280,6 +280,29 @@ export function createPlugins(
280280 } ,
281281 } ) ,
282282 )
283+
284+ // utility function that pushes a plugin
285+ function pushPlugin (
286+ nameTriggers : string [ ] ,
287+ [ moduleName , prop ] : [ modulesname : string , prop ?: string ] ,
288+ pluginDefaultOptions : object = { } ,
289+ includeByDefault : boolean = false
290+ ) {
291+ const index = includesAny ( inputPluginsNames , [ ...nameTriggers , moduleName ] )
292+ if ( index !== null ) {
293+ const modul = require ( moduleName )
294+ const pluginFunction = typeof prop === "string" ? modul [ prop ] : modul
295+ if ( typeof inputPluginsNames [ index ] === "string" ) {
296+ // plugin name only
297+ plugins . push ( pluginFunction ( pluginDefaultOptions ) )
298+ } else {
299+ // plugin with options
300+ plugins . push ( pluginFunction ( inputPluginsNames [ index ] [ 1 ] ) )
301+ }
302+ } else if ( includeByDefault ) {
303+ const modul = require ( moduleName )
304+ const pluginFunction = typeof prop === "string" ? modul [ prop ] : modul
305+ plugins . push ( pluginFunction ( pluginDefaultOptions ) )
283306 }
284307 }
285308
You can’t perform that action at this time.
0 commit comments