From 25b684564171f0719600d027b7b5d6056dbcae09 Mon Sep 17 00:00:00 2001 From: Chuan-kai Lin Date: Mon, 22 Sep 2025 15:25:02 -0700 Subject: [PATCH] Move support code into loadUserConfig() --- src/config-utils.ts | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/config-utils.ts b/src/config-utils.ts index 984476f97..ff5cd81a7 100644 --- a/src/config-utils.ts +++ b/src/config-utils.ts @@ -593,12 +593,24 @@ export function amendInputConfigFile( } } +/** + * Load user configuration from a file or return an empty configuration + * if no config file is specified. + */ async function loadUserConfig( - configFile: string, + configFile: string | undefined, workspacePath: string, apiDetails: api.GitHubApiCombinedDetails, tempDir: string, + logger: Logger, ): Promise { + if (!configFile) { + logger.debug("No configuration file was provided"); + return {}; + } + + logger.debug(`Using configuration file: ${configFile}`); + if (isLocal(configFile)) { if (configFile !== userConfigFromActionPath(tempDir)) { // If the config file is not generated by the Action, it should be relative to the workspace. @@ -863,19 +875,13 @@ export async function initConfig( ): Promise { const { logger, tempDir } = inputs; - let userConfig: UserConfig = {}; - if (!inputs.configFile) { - logger.debug("No configuration file was provided"); - } else { - logger.debug(`Using configuration file: ${inputs.configFile}`); - userConfig = await loadUserConfig( - inputs.configFile, - inputs.workspacePath, - inputs.apiDetails, - tempDir, - ); - } - + const userConfig = await loadUserConfig( + inputs.configFile, + inputs.workspacePath, + inputs.apiDetails, + tempDir, + logger, + ); const config = await initActionState(inputs, userConfig, codeql); // If Code Quality analysis is the only enabled analysis kind, then we will initialise