0
0
Fork 0
mirror of https://github.com/renovatebot/renovate.git synced 2025-05-12 15:41:58 +00:00
renovatebot_renovate/lib/util/env.ts
RahulGautamSingh 49fa1be464
feat(util): getEnv (#35161)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2025-05-06 18:37:28 +00:00

32 lines
767 B
TypeScript

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