@@ -155,6 +155,7 @@ export class Ghjkfile {
155
155
finalized : ReturnType < EnvFinalizer > ;
156
156
installSetId ?: string ;
157
157
vars : Record < string , string > ;
158
+ dynVars : Record < string , string > ;
158
159
envHash : string ;
159
160
}
160
161
> = { } ;
@@ -415,6 +416,7 @@ export class Ghjkfile {
415
416
416
417
#mergeEnvs( keys : string [ ] , childName : string ) {
417
418
const mergedVars = { } as Record < string , [ string , string ] | undefined > ;
419
+ const mergedDynVars = { } as Record < string , [ string , string ] | undefined > ;
418
420
let mergedInstalls = new Set < string > ( ) ;
419
421
const mergedOnEnterHooks = [ ] ;
420
422
const mergedOnExitHooks = [ ] ;
@@ -423,7 +425,12 @@ export class Ghjkfile {
423
425
[ string , string ] | undefined
424
426
> ;
425
427
for ( const parentName of keys ) {
426
- const { vars, installSetId, finalized } = this . #finalizedEnvs[ parentName ] ;
428
+ const {
429
+ vars,
430
+ dynVars,
431
+ installSetId,
432
+ finalized,
433
+ } = this . #finalizedEnvs[ parentName ] ;
427
434
mergedOnEnterHooks . push ( ...finalized . onEnterHookTasks ) ;
428
435
mergedOnExitHooks . push ( ...finalized . onExitHookTasks ) ;
429
436
for ( const [ key , val ] of Object . entries ( vars ) ) {
@@ -443,6 +450,22 @@ export class Ghjkfile {
443
450
}
444
451
mergedVars [ key ] = [ val , parentName ] ;
445
452
}
453
+
454
+ for ( const [ key , val ] of Object . entries ( dynVars ) ) {
455
+ const conflict = mergedDynVars [ key ] ;
456
+ if ( conflict && val !== conflict [ 0 ] ) {
457
+ logger . warn (
458
+ "dynamic environment variable conflict on multiple env inheritance, parent2 was chosen" ,
459
+ {
460
+ child : childName ,
461
+ parent1 : conflict [ 1 ] ,
462
+ parent2 : parentName ,
463
+ variable : key ,
464
+ } ,
465
+ ) ;
466
+ }
467
+ mergedDynVars [ key ] = [ val , parentName ] ;
468
+ }
446
469
if ( ! installSetId ) {
447
470
continue ;
448
471
}
0 commit comments