import * as memCache from './cache/memory/index.ts'; import { coerceObject } from './object.ts'; let customEnv: Record = {}; export function setCustomEnv(envObj: Record): void { customEnv = envObj; } export function getCustomEnv(): Record { return customEnv; } export function setUserEnv(envObj: Record | undefined): void { memCache.set('userEnv', envObj); } export function getUserEnv(): Record { return coerceObject(memCache.get('userEnv')); } /** * Combination of process.env, customEnvVariables and user configured env * * Precedence: userEnv > customEnvVariables > process.env */ export function getEnv(): Record { return { ...process.env, ...getCustomEnv(), ...getUserEnv(), }; }