import process from "node:process";
export function createDenoEnvStub(
input: Record<string, string>,
): typeof Deno.env {
return {
get(key: string) {
return input[key];
},
has(key: string) {
return input[key] !== undefined;
},
toObject() {
return { ...input };
},
set(_key: string, _value: string) {
},
delete(_key: string) {
},
};
}
export function setEnv(key: string, value: string) {
const env = Deno.env.toObject();
process.env = { ...env, [key]: value };
Object.defineProperty(Deno, "env", {
value: createDenoEnvStub({ ...env, [key]: value }),
});
}