fix(utils): update medusa config resolution for consistency (#9591)
This commit is contained in:
committed by
GitHub
parent
537567b679
commit
e9383f25e0
@@ -13,14 +13,14 @@ describe("configLoader", () => {
|
||||
|
||||
expect(configModule).toBeUndefined()
|
||||
|
||||
configLoader(entryDirectory, "medusa-config")
|
||||
await configLoader(entryDirectory, "medusa-config")
|
||||
|
||||
configModule = container.resolve(ContainerRegistrationKeys.CONFIG_MODULE)
|
||||
|
||||
expect(configModule).toBeDefined()
|
||||
expect(configModule.projectConfig.databaseName).toBeUndefined()
|
||||
|
||||
configLoader(entryDirectory, "medusa-config-2")
|
||||
await configLoader(entryDirectory, "medusa-config-2")
|
||||
|
||||
configModule = container.resolve(ContainerRegistrationKeys.CONFIG_MODULE)
|
||||
|
||||
@@ -30,7 +30,7 @@ describe("configLoader", () => {
|
||||
|
||||
process.env.MEDUSA_WORKER_MODE = "worker"
|
||||
|
||||
configLoader(entryDirectory, "medusa-config-2")
|
||||
await configLoader(entryDirectory, "medusa-config-2")
|
||||
|
||||
configModule = container.resolve(ContainerRegistrationKeys.CONFIG_MODULE)
|
||||
|
||||
|
||||
@@ -26,11 +26,14 @@ container.register(
|
||||
* @param entryDirectory The directory to find the config file from
|
||||
* @param configFileName The name of the config file to search for in the entry directory
|
||||
*/
|
||||
export function configLoader(
|
||||
export async function configLoader(
|
||||
entryDirectory: string,
|
||||
configFileName: string
|
||||
): ConfigModule {
|
||||
const config = getConfigFile<ConfigModule>(entryDirectory, configFileName)
|
||||
): Promise<ConfigModule> {
|
||||
const config = await getConfigFile<ConfigModule>(
|
||||
entryDirectory,
|
||||
configFileName
|
||||
)
|
||||
|
||||
if (config.error) {
|
||||
handleConfigError(config.error)
|
||||
|
||||
Reference in New Issue
Block a user