@@ -107,8 +107,8 @@ export async function resolveConnections(config: Configuration, resolver?: strin
107107 // 3. If 1 & 2 are false, try resolving the connections from the environment. If not found fail with error.
108108 if ( connectionsFileExists ) {
109109 connections = await resolveConnectionsFromFile ( filename ) ;
110- } else if ( resolver ) {
111- connections = await resolveConnectionsUsingResolver ( config , resolver ) ;
110+ } else if ( resolver || config . connectionResolver ) {
111+ connections = await resolveConnectionsUsingResolver ( resolver || config . connectionResolver ) ;
112112 } else {
113113 log ( 'Connections file not provided.' ) ;
114114
@@ -137,20 +137,12 @@ export async function resolveConnections(config: Configuration, resolver?: strin
137137 * @param {string } resolver
138138 * @returns {Promise<ConnectionConfig[]> }
139139 */
140- export async function resolveConnectionsUsingResolver (
141- config : Configuration ,
142- resolver : string
143- ) : Promise < ConnectionConfig [ ] > {
140+ export async function resolveConnectionsUsingResolver ( resolver : string ) : Promise < ConnectionConfig [ ] > {
144141 log ( 'Resolving connection resolver: %s' , resolver ) ;
145- const connectionResolver = resolver || config . connectionResolver ;
146142
147- const connectionResolverExists = await fs . exists ( connectionResolver ) ;
143+ const resolverPath = resolver ? path . resolve ( process . cwd ( ) , resolver ) : '' ;
148144
149- if ( ! connectionResolverExists ) {
150- throw new Error ( `Could not find the connection resolver '${ resolver } .` ) ;
151- }
152-
153- const { resolve } = ( await import ( connectionResolver ) ) as ConnectionResolver ;
145+ const { resolve } = ( await import ( resolverPath ) ) as ConnectionResolver ;
154146
155147 if ( ! resolve ) {
156148 throw new Error ( `Resolver '${ resolver } ' does not expose a 'resolve' function.` ) ;
@@ -224,7 +216,7 @@ export function resolveConnectionsFromEnv(): ConnectionConfig[] {
224216 * @returns {Promise<ConnectionConfig[]> }
225217 */
226218async function resolveConnectionsFromFile ( filename : string ) : Promise < ConnectionConfig [ ] > {
227- log ( 'Resolving file: %s' , filename ) ;
219+ log ( 'Resolving connections file: %s' , filename ) ;
228220
229221 const loaded = await fs . read ( filename ) ;
230222 const { connections } = JSON . parse ( loaded ) as ConnectionsFileSchema ;
0 commit comments