Extract logging statements to separate function

This commit is contained in:
Andrew Eisenberg
2022-10-03 08:17:27 -07:00
parent 59fbe34861
commit 5960ce1190
9 changed files with 35 additions and 30 deletions

View File

@@ -240,15 +240,7 @@ export async function runQueries(
const codeql = await getCodeQL(config.codeQLCmd);
if (await util.useCodeScanningConfigInCli(codeql, featureFlags)) {
logger.info(
"Code Scanning configuration file being processed in the codeql-action."
);
} else {
logger.info(
"Code Scanning configuration file being processed in the codeql CLI."
);
}
await util.logCodeScanningConfigInCli(codeql, featureFlags, logger);
for (const language of config.languages) {
const queries = config.queries[language];

View File

@@ -24,6 +24,7 @@ import {
codeQlVersionAbove,
getMlPoweredJsQueriesPack,
GitHubVersion,
logCodeScanningConfigInCli,
ML_POWERED_JS_QUERIES_PACK_NAME,
useCodeScanningConfigInCli,
} from "./util";
@@ -1704,10 +1705,9 @@ export async function initConfig(
// When using the codescanning config in the CLI, pack downloads
// happen in the CLI during the `database init` command, so no need
// to download them here.
await logCodeScanningConfigInCli(codeQL, featureFlags, logger);
if (!(await useCodeScanningConfigInCli(codeQL, featureFlags))) {
logger.info(
"Code Scanning configuration file being processed in the codeql CLI."
);
const registries = parseRegistries(registriesInput);
await downloadPacks(
codeQL,
@@ -1718,10 +1718,6 @@ export async function initConfig(
config.tempDir,
logger
);
} else {
logger.info(
"Code Scanning configuration file being processed in the codeql-action."
);
}
// Save the config so we can easily access it again in the future

View File

@@ -817,6 +817,22 @@ export async function useCodeScanningConfigInCli(
return await codeQlVersionAbove(codeql, CODEQL_VERSION_CONFIG_FILES);
}
export async function logCodeScanningConfigInCli(
codeql: CodeQL,
featureFlags: FeatureFlags,
logger: Logger
) {
if (await useCodeScanningConfigInCli(codeql, featureFlags)) {
logger.info(
"Code Scanning configuration file being processed in the codeql CLI."
);
} else {
logger.info(
"Code Scanning configuration file being processed in the codeql-action."
);
}
}
/*
* Returns whether the path in the argument represents an existing directory.
*/