renovate/lib/util/exec/env.ts
Martín Fernández 8da8d7a072 feat: Add DOCKER_HOST to child env (#5222)
Currently the DOCKER_HOST env variable is not passed to the child
environment making it impossible to use a non default docker host.
2020-01-25 19:30:43 +01:00

24 lines
532 B
TypeScript

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