@@ -514,6 +514,7 @@ export async function getCodeQLForCmd(
514514 ) ;
515515 if ( result === undefined ) {
516516 result = await runCliJson < VersionInfo > (
517+ env ,
517518 cmd ,
518519 [ "version" , "--format=json" ] ,
519520 {
@@ -597,6 +598,7 @@ export async function getCodeQLForCmd(
597598 : [ "--no-calculate-baseline" ] ;
598599
599600 await runCli (
601+ env ,
600602 cmd ,
601603 [
602604 "database" ,
@@ -663,10 +665,10 @@ export async function getCodeQLForCmd(
663665 // When `DYLD_INSERT_LIBRARIES` is set in the environment for a step,
664666 // the Actions runtime introduces its own workaround for SIP
665667 // (https://github.com/actions/runner/pull/416).
666- await runCli ( autobuildCmd ) ;
668+ await runCli ( env , autobuildCmd ) ;
667669 } ,
668670 async extractScannedLanguage ( config : Config , language : Language ) {
669- await runCli ( cmd , [
671+ await runCli ( env , cmd , [
670672 "database" ,
671673 "trace-command" ,
672674 "--index-traceless-dbs" ,
@@ -681,7 +683,7 @@ export async function getCodeQLForCmd(
681683 applyAutobuildAzurePipelinesTimeoutFix ( env ) ;
682684 }
683685 try {
684- await runCli ( cmd , [
686+ await runCli ( env , cmd , [
685687 "database" ,
686688 "trace-command" ,
687689 "--use-build-mode" ,
@@ -720,7 +722,7 @@ export async function getCodeQLForCmd(
720722 ...getExtraOptionsFromEnv ( [ "database" , "finalize" ] ) ,
721723 databasePath ,
722724 ] ;
723- await runCli ( cmd , args ) ;
725+ await runCli ( env , cmd , args ) ;
724726 } ,
725727 async resolveLanguages (
726728 {
@@ -729,7 +731,7 @@ export async function getCodeQLForCmd(
729731 filterToLanguagesWithQueries : boolean ;
730732 } = { filterToLanguagesWithQueries : false } ,
731733 ) {
732- return runCliJson < ResolveLanguagesOutput > ( cmd , [
734+ return runCliJson < ResolveLanguagesOutput > ( env , cmd , [
733735 "resolve" ,
734736 "languages" ,
735737 "--format=betterjson" ,
@@ -758,7 +760,11 @@ export async function getCodeQLForCmd(
758760 if ( workingDir !== undefined ) {
759761 codeqlArgs . push ( "--working-dir" , workingDir ) ;
760762 }
761- return await runCliJson < ResolveBuildEnvironmentOutput > ( cmd , codeqlArgs ) ;
763+ return await runCliJson < ResolveBuildEnvironmentOutput > (
764+ env ,
765+ cmd ,
766+ codeqlArgs ,
767+ ) ;
762768 } ,
763769 async databaseRunQueries (
764770 databasePath : string ,
@@ -777,7 +783,7 @@ export async function getCodeQLForCmd(
777783 ignoringOptions : [ "--expect-discarded-cache" ] ,
778784 } ) ,
779785 ] ;
780- await runCli ( cmd , codeqlArgs ) ;
786+ await runCli ( env , cmd , codeqlArgs ) ;
781787 } ,
782788 async databaseInterpretResults (
783789 databasePath : string ,
@@ -830,7 +836,7 @@ export async function getCodeQLForCmd(
830836 }
831837 // Capture the stdout, which contains the analysis summary. Don't stream it to the Actions
832838 // logs to avoid printing it twice.
833- return await runCli ( cmd , codeqlArgs , {
839+ return await runCli ( env , cmd , codeqlArgs , {
834840 noStreamStdout : true ,
835841 } ) ;
836842 } ,
@@ -847,7 +853,7 @@ export async function getCodeQLForCmd(
847853 `--cache-cleanup=${ cleanupLevel } ` ,
848854 ...getExtraOptionsFromEnv ( [ "database" , "cleanup" ] ) ,
849855 ] ;
850- await runCli ( cmd , codeqlArgs ) ;
856+ await runCli ( env , cmd , codeqlArgs ) ;
851857 }
852858 } ,
853859 async databaseBundle (
@@ -995,7 +1001,7 @@ export async function getCodeQLForCmd(
9951001 ...getExtraOptionsFromEnv ( [ "resolve" , "queries" ] ) ,
9961002 ...queries ,
9971003 ] ;
998- return await runCliJson < string [ ] > ( cmd , codeqlArgs , {
1004+ return await runCliJson < string [ ] > ( env , cmd , codeqlArgs , {
9991005 noStreamStdout : true ,
10001006 } ) ;
10011007 } ,
@@ -1009,7 +1015,7 @@ export async function getCodeQLForCmd(
10091015 "--format=json" ,
10101016 ...getExtraOptionsFromEnv ( [ "resolve" , "database" ] ) ,
10111017 ] ;
1012- return await runCliJson < ResolveDatabaseOutput > ( cmd , codeqlArgs , {
1018+ return await runCliJson < ResolveDatabaseOutput > ( env , cmd , codeqlArgs , {
10131019 noStreamStdout : true ,
10141020 } ) ;
10151021 } ,
@@ -1036,7 +1042,7 @@ export async function getCodeQLForCmd(
10361042 args . push ( "--sarif-merge-runs-from-equal-category" ) ;
10371043 }
10381044
1039- await runCli ( cmd , args ) ;
1045+ await runCli ( env , cmd , args ) ;
10401046 } ,
10411047 } ;
10421048 // To ensure that status reports include the CodeQL CLI version wherever
@@ -1153,12 +1159,13 @@ export function getExtraOptions(
11531159}
11541160
11551161async function runCli (
1162+ env : Env ,
11561163 cmd : string ,
11571164 args : string [ ] = [ ] ,
11581165 opts : { stdin ?: string ; noStreamStdout ?: boolean } = { } ,
11591166) : Promise < string > {
11601167 try {
1161- return await runTool ( cmd , args , opts ) ;
1168+ return await runTool ( env , cmd , args , opts ) ;
11621169 } catch ( e ) {
11631170 if ( e instanceof CommandInvocationError ) {
11641171 throw wrapCliConfigurationError ( new CliError ( e ) ) ;
@@ -1169,6 +1176,8 @@ async function runCli(
11691176
11701177/**
11711178 * Wraps the command executor {@link runCli} and tries to parse the output as JSON.
1179+ *
1180+ * @param env The environment variables.
11721181 * @param cmd The command to run.
11731182 * @param args The arguments to pass to the command.
11741183 * @param opts The options for running the command.
@@ -1177,11 +1186,12 @@ async function runCli(
11771186 * @returns The parsed JSON output from the command.
11781187 */
11791188async function runCliJson < T > (
1189+ env : Env ,
11801190 cmd : string ,
11811191 args : string [ ] = [ ] ,
11821192 opts : { stdin ?: string ; noStreamStdout ?: boolean } = { } ,
11831193) : Promise < T > {
1184- const output = await runCli ( cmd , args , opts ) ;
1194+ const output = await runCli ( env , cmd , args , opts ) ;
11851195 try {
11861196 return JSON . parse ( output ) as T ;
11871197 } catch ( e ) {
0 commit comments