chore: use loaded module reference (#5763)

This commit is contained in:
Carlos R. L. Rodrigues
2024-01-23 08:31:02 -03:00
committed by GitHub
parent bc79edfa67
commit d85fee42ee
25 changed files with 291 additions and 191 deletions

View File

@@ -121,11 +121,13 @@ export async function loadInternalModule(
}
export async function loadModuleMigrations(
resolution: ModuleResolution
resolution: ModuleResolution,
moduleExports?: ModuleExports
): Promise<[Function | undefined, Function | undefined]> {
let loadedModule: ModuleExports
try {
loadedModule = await import(resolution.resolutionPath as string)
loadedModule =
moduleExports ?? (await import(resolution.resolutionPath as string))
return [loadedModule.runMigrations, loadedModule.revertMigration]
} catch {