renovate/lib/util/exec/env.ts
2021-05-19 13:37:27 +02:00

33 lines
698 B
TypeScript

import { getAdminConfig } from '../../config/admin';
const basicEnvVars = [
'HTTP_PROXY',
'HTTPS_PROXY',
'NO_PROXY',
'http_proxy',
'https_proxy',
'no_proxy',
'HOME',
'PATH',
'LC_ALL',
'LANG',
'DOCKER_HOST',
'DOCKER_TLS_VERIFY',
'DOCKER_CERT_PATH',
];
export function getChildProcessEnv(
customEnvVars: string[] = []
): NodeJS.ProcessEnv {
const env: NodeJS.ProcessEnv = {};
if (getAdminConfig().exposeAllEnv) {
return { ...env, ...process.env };
}
const envVars = [...basicEnvVars, ...customEnvVars];
envVars.forEach((envVar) => {
if (typeof process.env[envVar] !== 'undefined') {
env[envVar] = process.env[envVar];
}
});
return env;
}