Fix() Try to load index files (#1016)
This commit is contained in:
1 parent
9bb544e967
commit
88ac3c0785
1 file changed
+4
-3
@@ -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
|
||||||
|
if (loaded) {
|
||||||
const name = formatRegistrationName(fn)
|
const name = formatRegistrationName(fn)
|
||||||
container.register({
|
container.register({
|
||||||
[name]: asFunction(
|
[name]: asFunction(
|
||||||
cradle => new loaded(cradle, configModule)
|
cradle => new loaded(cradle, configModule),
|
||||||
).singleton(),
|
).singleton(),
|
||||||
})
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user