mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-24 14:34:21 +00:00
c32e2391a0
Refs #45216 The object counterpart to `prefer-coerce-array`: `x ?? {}` becomes `coerceObject(x)`. The rule flags a `??` whose default is a bare `{}` literal, so a populated default or an asserted `({} as Foo)` still passes; a `x ?? y ?? {}` chain maps onto `coerceObject(x, y)`. Every hit across `lib/` converted cleanly, so no disable comments were needed.
34 lines
828 B
TypeScript
34 lines
828 B
TypeScript
import * as memCache from './cache/memory/index.ts';
|
|
import { coerceObject } from './object.ts';
|
|
|
|
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 coerceObject(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(),
|
|
};
|
|
}
|