Fix() Try to load index files (#1016)

This commit is contained in:
Adrien de Peretti authored and GitHub committed 2022-02-15 10:39:29 +01:00
1 parent ba77fc920f
commit 6f339e366a
1 file changed
+9 -8
+9 -8
View File
@@ -1,7 +1,6 @@
import { BaseService, PaymentService } from "medusa-interfaces"
import glob from "glob" import glob from "glob"
import path from "path" import path from "path"
import { Lifetime, asFunction } from "awilix" import { asFunction } from "awilix"
import formatRegistrationName from "../utils/format-registration-name" import formatRegistrationName from "../utils/format-registration-name"
@@ -17,11 +16,13 @@ export default ({ container, configModule }) => {
const core = glob.sync(coreFull, { cwd: __dirname }) const core = glob.sync(coreFull, { cwd: __dirname })
core.forEach(fn => { core.forEach(fn => {
const loaded = require(fn).default const loaded = require(fn).default
const name = formatRegistrationName(fn) if (loaded) {
container.register({ const name = formatRegistrationName(fn)
[name]: asFunction( container.register({
cradle => new loaded(cradle, configModule) [name]: asFunction(
).singleton(), cradle => new loaded(cradle, configModule),
}) ).singleton(),
})
}
}) })
} }