Skip to content

Commit

Permalink
feat(tabstractdatabase): allow to use wrapper function named register…
Browse files Browse the repository at this point in the history
…Plugin to allow multiexport
  • Loading branch information
Itee committed Mar 2, 2022
1 parent d24ac74 commit 6a401c7
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions sources/databases/TAbstractDatabase.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,12 @@ class TAbstractDatabase extends TAbstractObject {

try {

const plugin = require( name )( config )
//[Itee:01/03/2022] Todo: Waiting better plugin management for package that expose more than instancied plugin
let plugin = require( name )
if(plugin.registerPlugin) {
plugin = plugin.registerPlugin( config )
}

if ( plugin instanceof TAbstractDatabasePlugin ) {

this.logger.log( `Use ${ name } plugin from node_modules` )
Expand Down Expand Up @@ -198,9 +203,13 @@ class TAbstractDatabase extends TAbstractObject {

try {

//[Itee:01/03/2022] Todo: Waiting better plugin management for package that expose more than instancied plugin
// todo use rootPath or need to resolve depth correctly !
const localPluginPath = path.join( __dirname, '../../../', 'databases/plugins/', name, `${ name }.js` )
const plugin = require( localPluginPath )( config )
let plugin = require( localPluginPath )
if(plugin.registerPlugin) {
plugin = plugin.registerPlugin( config )
}

if ( plugin instanceof TAbstractDatabasePlugin ) {

Expand Down

0 comments on commit 6a401c7

Please sign in to comment.