File tree Expand file tree Collapse file tree 8 files changed +19
-34
lines changed
Expand file tree Collapse file tree 8 files changed +19
-34
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { GlobalConfig } from '../../../config/global';
44import { logger } from '../../../logger' ;
55import * as memCache from '../../../util/cache/memory' ;
66import { cache } from '../../../util/cache/package/decorator' ;
7- import { getChildProcessEnv } from '../../../util/exec/env ' ;
7+ import { getChildEnv } from '../../../util/exec/utils ' ;
88import { privateCacheDir , readCacheFile } from '../../../util/fs' ;
99import { simpleGitConfig } from '../../../util/git/config' ;
1010import { toSha256 } from '../../../util/hash' ;
@@ -323,7 +323,7 @@ export class CrateDatasource extends Datasource {
323323 const git = Git ( {
324324 ...simpleGitConfig ( ) ,
325325 maxConcurrentProcesses : 1 ,
326- } ) . env ( getChildProcessEnv ( ) ) ;
326+ } ) . env ( getChildEnv ( ) ) ;
327327 const clonePromise = git . clone ( registryFetchUrl , clonePath , {
328328 '--depth' : 1 ,
329329 } ) ;
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import is from '@sindresorhus/is';
22import { simpleGit } from 'simple-git' ;
33import { logger } from '../../../logger' ;
44import { cache } from '../../../util/cache/package/decorator' ;
5- import { getChildProcessEnv } from '../../../util/exec/env ' ;
5+ import { getChildEnv } from '../../../util/exec/utils ' ;
66import { getGitEnvironmentVariables } from '../../../util/git/auth' ;
77import { simpleGitConfig } from '../../../util/git/config' ;
88import { getRemoteUrlWithToken } from '../../../util/git/url' ;
@@ -34,12 +34,7 @@ export abstract class GitDatasource extends Datasource {
3434 const gitSubmoduleAuthEnvironmentVariables = getGitEnvironmentVariables ( [
3535 this . id ,
3636 ] ) ;
37- const gitEnv = {
38- // pass all existing env variables
39- ...getChildProcessEnv ( ) ,
40- // add all known git Variables
41- ...gitSubmoduleAuthEnvironmentVariables ,
42- } ;
37+ const gitEnv = getChildEnv ( { env : gitSubmoduleAuthEnvironmentVariables } ) ;
4338 const git = simpleGit ( simpleGitConfig ( ) ) . env ( gitEnv ) ;
4439
4540 // fetch remote tags
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import Git from 'simple-git';
44import upath from 'upath' ;
55import { GlobalConfig } from '../../../config/global' ;
66import { logger } from '../../../logger' ;
7- import { getChildProcessEnv } from '../../../util/exec/env ' ;
7+ import { getChildEnv } from '../../../util/exec/utils ' ;
88import { getGitEnvironmentVariables } from '../../../util/git/auth' ;
99import { simpleGitConfig } from '../../../util/git/config' ;
1010import { getHttpUrl } from '../../../util/git/url' ;
@@ -44,12 +44,7 @@ async function getDefaultBranch(subModuleUrl: string): Promise<string> {
4444 'git-tags' ,
4545 'git-refs' ,
4646 ] ) ;
47- const gitEnv = {
48- // pass all existing env variables
49- ...getChildProcessEnv ( ) ,
50- // add all known git Variables
51- ...gitSubmoduleAuthEnvironmentVariables ,
52- } ;
47+ const gitEnv = getChildEnv ( { env : gitSubmoduleAuthEnvironmentVariables } ) ;
5348 const val = await Git ( simpleGitConfig ( ) )
5449 . env ( gitEnv )
5550 . listRemote ( [ '--symref' , subModuleUrl , 'HEAD' ] ) ;
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import Git from 'simple-git';
22import upath from 'upath' ;
33import { GlobalConfig } from '../../../config/global' ;
44import { logger } from '../../../logger' ;
5- import { getChildProcessEnv } from '../../../util/exec/env ' ;
5+ import { getChildEnv } from '../../../util/exec/utils ' ;
66import { readLocalFile } from '../../../util/fs' ;
77import { getGitEnvironmentVariables } from '../../../util/git/auth' ;
88import type { UpdateDependencyConfig } from '../types' ;
@@ -16,12 +16,7 @@ export default async function updateDependency({
1616 'git-tags' ,
1717 'git-refs' ,
1818 ] ) ;
19- const gitEnv = {
20- // pass all existing env variables
21- ...getChildProcessEnv ( ) ,
22- // add all known git Variables
23- ...gitSubmoduleAuthEnvironmentVariables ,
24- } ;
19+ const gitEnv = getChildEnv ( { env : gitSubmoduleAuthEnvironmentVariables } ) ;
2520 const git = Git ( localDir ) . env ( gitEnv ) ;
2621 const submoduleGit = Git ( upath . join ( localDir , upgrade . depName ) ) . env ( gitEnv ) ;
2722
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import deepmerge from 'deepmerge';
44import upath from 'upath' ;
55import { logger } from '../../../../logger' ;
66import { ExternalHostError } from '../../../../types/errors/external-host-error' ;
7- import { getChildProcessEnv } from '../../../../util/exec /env' ;
7+ import { getEnv } from '../../../../util/env' ;
88import {
99 ensureCacheDir ,
1010 getSiblingFileName ,
@@ -391,8 +391,10 @@ export async function getAdditionalFiles(
391391
392392 const { additionalNpmrcContent, additionalYarnRcYml } = processHostRules ( ) ;
393393
394+ // This isn't passed directly to the child process, so no need to filter.
395+ // But pass custom env and user vars.
394396 const env = {
395- ...getChildProcessEnv ( ) ,
397+ ...getEnv ( ) ,
396398 NPM_CONFIG_CACHE : await ensureCacheDir ( 'npm' ) ,
397399 YARN_CACHE_FOLDER : await ensureCacheDir ( 'yarn' ) ,
398400 YARN_GLOBAL_FOLDER : await ensureCacheDir ( 'berry' ) ,
Original file line number Diff line number Diff line change 11import { GlobalConfig } from '../../config/global' ;
2- import { getEnv } from '../env' ;
32
43const basicEnvVars = [
54 'HTTP_PROXY' ,
@@ -43,22 +42,21 @@ const basicEnvVars = [
4342export function getChildProcessEnv (
4443 customEnvVars : string [ ] = [ ] ,
4544) : NodeJS . ProcessEnv {
46- const combinedEnv = getEnv ( ) ;
4745 const env : NodeJS . ProcessEnv = { } ;
4846 if ( GlobalConfig . get ( 'exposeAllEnv' ) ) {
49- return { ...combinedEnv } ;
47+ return { ...process . env } ;
5048 }
5149 const envVars = [ ...basicEnvVars , ...customEnvVars ] ;
5250 envVars . forEach ( ( envVar ) => {
53- if ( typeof combinedEnv [ envVar ] !== 'undefined' ) {
54- env [ envVar ] = combinedEnv [ envVar ] ;
51+ if ( typeof process . env [ envVar ] !== 'undefined' ) {
52+ env [ envVar ] = process . env [ envVar ] ;
5553 }
5654 } ) ;
5755
5856 // Copy containerbase url replacements
59- for ( const key of Object . keys ( combinedEnv ) ) {
57+ for ( const key of Object . keys ( process . env ) ) {
6058 if ( / ^ U R L _ R E P L A C E _ \d + _ (?: F R O M | T O ) $ / . test ( key ) ) {
61- env [ key ] = combinedEnv [ key ] ;
59+ env [ key ] = process . env [ key ] ;
6260 }
6361 }
6462 return env ;
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import type { ExecOptions } from './types';
66export function getChildEnv ( {
77 extraEnv,
88 env : forcedEnv = { } ,
9- } : ExecOptions ) : Record < string , string > {
9+ } : Pick < ExecOptions , 'env' | 'extraEnv' > = { } ) : Record < string , string > {
1010 const globalConfigEnv = getCustomEnv ( ) ;
1111 const userConfiguredEnv = getUserEnv ( ) ;
1212
Original file line number Diff line number Diff line change @@ -238,7 +238,7 @@ export async function initRepo(args: StorageConfig): Promise<void> {
238238 config . ignoredAuthors = [ ] ;
239239 config . additionalBranches = [ ] ;
240240 config . branchIsModified = { } ;
241- // TODO: safe to pass all env variables?
241+ // TODO: safe to pass all env variables? use `getChildEnv` instead?
242242 git = simpleGit ( GlobalConfig . get ( 'localDir' ) , simpleGitConfig ( ) ) . env ( {
243243 ...getEnv ( ) ,
244244 LANG : 'C.UTF-8' ,
You can’t perform that action at this time.
0 commit comments