@@ -124,7 +124,7 @@ export function findDwJson(startDir: string = process.cwd()): string | undefined
124124 * 2. Config marked as `active: true`
125125 * 3. Root-level config
126126 */
127- function selectConfig ( json : DwJsonMultiConfig , instanceName ?: string ) : DwJsonConfig {
127+ function selectConfig ( json : DwJsonMultiConfig , instanceName ?: string ) : DwJsonConfig | undefined {
128128 const logger = getLogger ( ) ;
129129
130130 // Single config or no configs array
@@ -152,11 +152,9 @@ function selectConfig(json: DwJsonMultiConfig, instanceName?: string): DwJsonCon
152152 logger . trace ( { selection : 'named' , instanceName} , `[DwJsonSource] Selected config "${ instanceName } " by name` ) ;
153153 return found ;
154154 }
155- // Instance not found, fall through to other selection methods
156- logger . trace (
157- { requestedInstance : instanceName } ,
158- `[DwJsonSource] Named instance "${ instanceName } " not found, falling back` ,
159- ) ;
155+ // Instance explicitly requested but not found - return undefined
156+ logger . trace ( { requestedInstance : instanceName } , `[DwJsonSource] Named instance "${ instanceName } " not found` ) ;
157+ return undefined ;
160158 }
161159
162160 // Find active config
@@ -224,8 +222,12 @@ export function loadDwJson(options: LoadDwJsonOptions = {}): LoadDwJsonResult |
224222 try {
225223 const content = fs . readFileSync ( dwJsonPath , 'utf8' ) ;
226224 const json = JSON . parse ( content ) as DwJsonMultiConfig ;
225+ const config = selectConfig ( json , options . instance ) ;
226+ if ( ! config ) {
227+ return undefined ;
228+ }
227229 return {
228- config : selectConfig ( json , options . instance ) ,
230+ config,
229231 path : dwJsonPath ,
230232 } ;
231233 } catch ( error ) {
0 commit comments