Skip to content

Commit a81dba4

Browse files
committed
wip
1 parent db40575 commit a81dba4

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

examples/kitchen/ghjk.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ env("python")
107107
ports.cpy_bs({ version: "3.8.18", releaseTag: "20240224" }),
108108
ports.tar(),
109109
ports.zstd(),
110-
);
110+
)
111+
.mixin(pyEnv());
111112

112113
env("dev")
113114
// we can inherit from many envs
@@ -123,4 +124,4 @@ env("dev")
123124
}));
124125

125126
env("venv")
126-
.mixin(pyEnv({ install: { version: "3.8.18", releaseTag: "20240224" } }));
127+
.inherit(["python"]);

files/mod.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ export class Ghjkfile {
155155
finalized: ReturnType<EnvFinalizer>;
156156
installSetId?: string;
157157
vars: Record<string, string>;
158+
dynVars: Record<string, string>;
158159
envHash: string;
159160
}
160161
> = {};
@@ -415,6 +416,7 @@ export class Ghjkfile {
415416

416417
#mergeEnvs(keys: string[], childName: string) {
417418
const mergedVars = {} as Record<string, [string, string] | undefined>;
419+
const mergedDynVars = {} as Record<string, [string, string] | undefined>;
418420
let mergedInstalls = new Set<string>();
419421
const mergedOnEnterHooks = [];
420422
const mergedOnExitHooks = [];
@@ -423,7 +425,12 @@ export class Ghjkfile {
423425
[string, string] | undefined
424426
>;
425427
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];
427434
mergedOnEnterHooks.push(...finalized.onEnterHookTasks);
428435
mergedOnExitHooks.push(...finalized.onExitHookTasks);
429436
for (const [key, val] of Object.entries(vars)) {
@@ -443,6 +450,22 @@ export class Ghjkfile {
443450
}
444451
mergedVars[key] = [val, parentName];
445452
}
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+
}
446469
if (!installSetId) {
447470
continue;
448471
}

0 commit comments

Comments
 (0)