Skip to content

Commit

Permalink
fix(tabstractdatabase): fix plugin setter and plugin config usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Itee committed Jul 7, 2021
1 parent f315d23 commit b11ecf6
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions sources/databases/TAbstractDatabase.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class TAbstractDatabase extends TAbstractObject {

if ( isNull( value ) ) { throw new TypeError( 'Plugins cannot be null ! Expect an array of TDatabasePlugin.' ) }
if ( isUndefined( value ) ) { throw new TypeError( 'Plugins cannot be undefined ! Expect an array of TDatabasePlugin.' ) }
if ( isNotArray( value ) ) { throw new TypeError( 'Plugins cannot be undefined ! Expect an array of TDatabasePlugin.' ) }

this._plugins = value
this._registerPlugins()
Expand Down Expand Up @@ -159,13 +158,13 @@ class TAbstractDatabase extends TAbstractObject {

}

_registerPackagePlugin ( name ) {
_registerPackagePlugin ( name, config ) {

let success = false

try {

const plugin = require( name )
const plugin = require( name )( config )
if ( plugin instanceof TAbstractDatabasePlugin ) {

this.logger.log( `Use ${ name } plugin from node_modules` )
Expand Down Expand Up @@ -194,15 +193,15 @@ class TAbstractDatabase extends TAbstractObject {

}

_registerLocalPlugin ( name ) {
_registerLocalPlugin ( name, config ) {

let success = false

try {

// todo use rootPath or need to resolve depth correctly !
const localPluginPath = path.join( __dirname, '../../../', 'databases/plugins/', name, `${ name }.js` )
const plugin = require( localPluginPath )
const plugin = require( localPluginPath )( config )

if ( plugin instanceof TAbstractDatabasePlugin ) {

Expand Down

0 comments on commit b11ecf6

Please sign in to comment.