renovate/lib/util/exec/env.ts
2020-01-14 12:12:03 +01:00

17 lines
502 B
TypeScript

const basicEnvVars = ['HTTP_PROXY', 'HTTPS_PROXY', 'NO_PROXY', 'HOME', 'PATH'];
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;
}