mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-25 06:51:11 +00:00
a9c8f7431f
This now covers everything that isn't `isObject` or `typeof x === 'number'`. Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>
83 lines
2.0 KiB
TypeScript
83 lines
2.0 KiB
TypeScript
import { isUndefined } from '@sindresorhus/is';
|
|
import { GlobalConfig } from '../../config/global.ts';
|
|
import { regEx } from '../regex.ts';
|
|
|
|
export 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',
|
|
// Custom certificate variables
|
|
// https://github.com/containerbase/base/blob/main/docs/custom-root-ca.md
|
|
'SSL_CERT_DIR',
|
|
'SSL_CERT_FILE',
|
|
'NODE_EXTRA_CA_CERTS',
|
|
'GIT_SSL_CAPATH',
|
|
'GIT_SSL_CAINFO',
|
|
// Required for NuGet to work on Windows.
|
|
'PROGRAMFILES',
|
|
'PROGRAMFILES(X86)',
|
|
'APPDATA',
|
|
'LOCALAPPDATA',
|
|
// Required for .NET dotnet-install.ps1 to work on Windows.
|
|
'PROCESSOR_ARCHITECTURE',
|
|
'PATHEXT',
|
|
// Corepack: https://github.com/nodejs/corepack
|
|
'COREPACK_DEFAULT_TO_LATEST',
|
|
'COREPACK_ENABLE_NETWORK',
|
|
'COREPACK_ENABLE_STRICT',
|
|
'COREPACK_ENABLE_PROJECT_SPEC',
|
|
'COREPACK_ENABLE_UNSAFE_CUSTOM_URLS',
|
|
'COREPACK_HOME',
|
|
'COREPACK_INTEGRITY_KEYS',
|
|
'COREPACK_NPM_REGISTRY',
|
|
'COREPACK_NPM_TOKEN',
|
|
'COREPACK_NPM_USERNAME',
|
|
'COREPACK_NPM_PASSWORD',
|
|
'COREPACK_ROOT',
|
|
// pnpm specific variables
|
|
'PNPM_WORKERS',
|
|
'PNPM_MAX_WORKERS',
|
|
] as const;
|
|
|
|
export const hardcodedProcessEnv: Readonly<NodeJS.ProcessEnv> = {
|
|
CI: 'true',
|
|
} as const;
|
|
|
|
export function getChildProcessEnv(
|
|
customEnvVars: string[] = [],
|
|
): NodeJS.ProcessEnv {
|
|
const env: NodeJS.ProcessEnv = {};
|
|
if (GlobalConfig.get('exposeAllEnv')) {
|
|
return { ...process.env, ...hardcodedProcessEnv };
|
|
}
|
|
const envVars = [...basicEnvVars, ...customEnvVars];
|
|
envVars.forEach((envVar) => {
|
|
if (!isUndefined(process.env[envVar])) {
|
|
env[envVar] = process.env[envVar];
|
|
}
|
|
});
|
|
|
|
// Copy containerbase url replacements
|
|
for (const key of Object.keys(process.env)) {
|
|
if (regEx(/^URL_REPLACE_\d+_(?:FROM|TO)$/).test(key)) {
|
|
env[key] = process.env[key];
|
|
}
|
|
}
|
|
|
|
for (const [key, value] of Object.entries(hardcodedProcessEnv)) {
|
|
env[key] = value;
|
|
}
|
|
|
|
return env;
|
|
}
|