@@ -13,7 +13,7 @@ import {
1313} from "./actions-util" ;
1414import * as api from "./api-client" ;
1515import { CliError , wrapCliConfigurationError } from "./cli-errors" ;
16- import { type Config } from "./config-utils" ;
16+ import { generateCodeScanningConfig , type Config } from "./config-utils" ;
1717import { DocUrl } from "./doc-url" ;
1818import { EnvVar } from "./environment" ;
1919import {
@@ -35,7 +35,7 @@ import { ToolsDownloadStatusReport } from "./tools-download";
3535import { ToolsFeature , isSupportedToolsFeature } from "./tools-features" ;
3636import { shouldEnableIndirectTracing } from "./tracer-config" ;
3737import * as util from "./util" ;
38- import { BuildMode , cloneObject , getErrorMessage } from "./util" ;
38+ import { BuildMode , getErrorMessage } from "./util" ;
3939
4040type Options = Array < string | number | boolean > ;
4141
@@ -574,7 +574,7 @@ export async function getCodeQLForCmd(
574574 extraArgs . push ( `--trace-process-name=${ processName } ` ) ;
575575 }
576576
577- const codeScanningConfigFile = await generateCodeScanningConfig (
577+ const codeScanningConfigFile = await writeCodeScanningConfigFile (
578578 config ,
579579 logger ,
580580 ) ;
@@ -1217,66 +1217,15 @@ async function runCli(
12171217 * @param config The configuration to use.
12181218 * @returns the path to the generated user configuration file.
12191219 */
1220- async function generateCodeScanningConfig (
1220+ async function writeCodeScanningConfigFile (
12211221 config : Config ,
12221222 logger : Logger ,
12231223) : Promise < string > {
12241224 const codeScanningConfigFile = getGeneratedCodeScanningConfigPath ( config ) ;
1225-
1226- // make a copy so we can modify it
1227- const augmentedConfig = cloneObject ( config . originalUserInput ) ;
1228-
1229- // Inject the queries from the input
1230- if ( config . augmentationProperties . queriesInput ) {
1231- if ( config . augmentationProperties . queriesInputCombines ) {
1232- augmentedConfig . queries = ( augmentedConfig . queries || [ ] ) . concat (
1233- config . augmentationProperties . queriesInput ,
1234- ) ;
1235- } else {
1236- augmentedConfig . queries = config . augmentationProperties . queriesInput ;
1237- }
1238- }
1239- if ( augmentedConfig . queries ?. length === 0 ) {
1240- delete augmentedConfig . queries ;
1241- }
1242-
1243- // Inject the packs from the input
1244- if ( config . augmentationProperties . packsInput ) {
1245- if ( config . augmentationProperties . packsInputCombines ) {
1246- // At this point, we already know that this is a single-language analysis
1247- if ( Array . isArray ( augmentedConfig . packs ) ) {
1248- augmentedConfig . packs = ( augmentedConfig . packs || [ ] ) . concat (
1249- config . augmentationProperties . packsInput ,
1250- ) ;
1251- } else if ( ! augmentedConfig . packs ) {
1252- augmentedConfig . packs = config . augmentationProperties . packsInput ;
1253- } else {
1254- // At this point, we know there is only one language.
1255- // If there were more than one language, an error would already have been thrown.
1256- const language = Object . keys ( augmentedConfig . packs ) [ 0 ] ;
1257- augmentedConfig . packs [ language ] = augmentedConfig . packs [
1258- language
1259- ] . concat ( config . augmentationProperties . packsInput ) ;
1260- }
1261- } else {
1262- augmentedConfig . packs = config . augmentationProperties . packsInput ;
1263- }
1264- }
1265- if ( Array . isArray ( augmentedConfig . packs ) && ! augmentedConfig . packs . length ) {
1266- delete augmentedConfig . packs ;
1267- }
1268-
1269- augmentedConfig [ "query-filters" ] = [
1270- // Ordering matters. If the first filter is an inclusion, it implicitly
1271- // excludes all queries that are not included. If it is an exclusion,
1272- // it implicitly includes all queries that are not excluded. So user
1273- // filters (if any) should always be first to preserve intent.
1274- ...( augmentedConfig [ "query-filters" ] || [ ] ) ,
1275- ...( config . augmentationProperties . extraQueryExclusions || [ ] ) ,
1276- ] ;
1277- if ( augmentedConfig [ "query-filters" ] ?. length === 0 ) {
1278- delete augmentedConfig [ "query-filters" ] ;
1279- }
1225+ const augmentedConfig = generateCodeScanningConfig (
1226+ config . originalUserInput ,
1227+ config . augmentationProperties ,
1228+ ) ;
12801229
12811230 logger . info (
12821231 `Writing augmented user configuration file to ${ codeScanningConfigFile } ` ,
0 commit comments