Move support code into loadUserConfig()

This commit is contained in:
Chuan-kai Lin
2025-09-22 15:25:02 -07:00
parent c079287f80
commit 25b6845641
+20 -14
View File
@@ -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<UserConfig> {
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<Config> {
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