fix(medusa): Plugin repository loader (#3345)
* fix(medusa): Plugin repository loader * Create brave-goats-pay.md --------- Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
8424236799
commit
e143a86976
5
.changeset/brave-goats-pay.md
Normal file
5
.changeset/brave-goats-pay.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@medusajs/medusa": patch
|
||||
---
|
||||
|
||||
fix(medusa): Plugin repository loader to work with Typeorm update
|
||||
@@ -1,4 +1,4 @@
|
||||
import { aliasTo, asClass, asFunction, asValue } from "awilix"
|
||||
import { aliasTo, asFunction, asValue } from "awilix"
|
||||
import { Express } from "express"
|
||||
import fs from "fs"
|
||||
import { sync as existsSync } from "fs-exists-cached"
|
||||
@@ -495,18 +495,16 @@ function registerRepositories(
|
||||
): void {
|
||||
const files = glob.sync(`${pluginDetails.resolve}/repositories/*.js`, {})
|
||||
files.forEach((fn) => {
|
||||
const loaded = require(fn) as ClassConstructor<unknown>
|
||||
const loaded = require(fn)
|
||||
|
||||
Object.entries(loaded).map(
|
||||
([, val]: [string, ClassConstructor<unknown>]) => {
|
||||
if (typeof val === "function") {
|
||||
const name = formatRegistrationName(fn)
|
||||
container.register({
|
||||
[name]: asClass(val),
|
||||
})
|
||||
}
|
||||
Object.entries(loaded).map(([, val]: [string, any]) => {
|
||||
if (typeof loaded === "object") {
|
||||
const name = formatRegistrationName(fn)
|
||||
container.register({
|
||||
[name]: asValue(val),
|
||||
})
|
||||
}
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user