mirror of
https://github.com/github/codeql-action
synced 2026-12-01 13:49:37 +08:00
Add and use clone method for ReadOnlyEnv
This commit is contained in:
3 files changed
+10
-1
No files matched your search
Generated
+4
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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>)
|
||||
|
||||
Reference in new issue
Block a user