renovate/lib/util/exec/env.ts
renovate[bot] 4f59b62da4
chore(deps): update dependency prettier to v2 (#5952)
* chore(deps): update dependency prettier to v2

* Run prettier-fix

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Jamie Magee <jamie.magee@gmail.com>
2020-04-12 18:09:36 +02:00

26 lines
556 B
TypeScript

const basicEnvVars = [
'HTTP_PROXY',
'HTTPS_PROXY',
'NO_PROXY',
'HOME',
'PATH',
'LC_ALL',
'LANG',
'DOCKER_HOST',
];
export function getChildProcessEnv(
customEnvVars: string[] = []
): NodeJS.ProcessEnv {
const env: NodeJS.ProcessEnv = {};
if (global.trustLevel === 'high') {
return Object.assign(env, process.env);
}
const envVars = [...basicEnvVars, ...customEnvVars];
envVars.forEach((envVar) => {
if (typeof process.env[envVar] !== 'undefined') {
env[envVar] = process.env[envVar];
}
});
return env;
}