Add and use clone method for ReadOnlyEnv

This commit is contained in:
Michael B. Gale committed 2026-07-14 16:59:51 +01:00
1 parent 205b37b035
commit b946565527
3 files changed
+10 -1

No files matched your search

+4
View File
@@ -141488,6 +141488,10 @@ var ReadOnlyEnv = class {
this.vars = vars;
}
vars;
/** Clones the object while detaching the underlying environment from the original. */
clone() {
return Object.create(this, { vars: { value: { ...this.vars } } });
}
/** Tries to get the value for `name` and throws if there isn't one. */
getRequired(name) {
return getRequiredEnvVar(this.vars, name);
+5
View File
@@ -265,6 +265,11 @@ export function getOptionalEnvVar(paramName: string): string | undefined {
export class ReadOnlyEnv<T extends string | undefined = string | undefined> {
constructor(protected readonly vars: Record<string, T>) {}
/** Clones the object while detaching the underlying environment from the original. */
public clone(): this {
return Object.create(this, { vars: { value: { ...this.vars } } }) as this;
}
/** Tries to get the value for `name` and throws if there isn't one. */
public getRequired(name: string): string {
return getRequiredEnvVar(this.vars, name);
+1 -1
View File
@@ -240,7 +240,7 @@ abstract class BaseEnvBuilder<
cloneFrom !== undefined
? ({
...cloneFrom.state,
env: Object.create(cloneFrom.state.env),
env: cloneFrom.state.env.clone(),
actions: Object.create(cloneFrom.state.actions),
logger: this.logger,
} satisfies ActionState<AllState>)