Use nullish conversion for packs
Slightly simplifies the `parsePacks` function.
This commit is contained in:
parent
49b2220f92
commit
96e7de35af
3 changed files with 9 additions and 11 deletions
6
lib/config-utils.js
generated
6
lib/config-utils.js
generated
|
|
@ -441,6 +441,7 @@ exports.getDefaultConfig = getDefaultConfig;
|
|||
* Load the config from the given file.
|
||||
*/
|
||||
async function loadConfig(languagesInput, queriesInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger) {
|
||||
var _a;
|
||||
let parsedYAML;
|
||||
if (isLocal(configFile)) {
|
||||
// Treat the config file as relative to the workspace
|
||||
|
|
@ -522,7 +523,7 @@ async function loadConfig(languagesInput, queriesInput, configFile, dbLocation,
|
|||
paths.push(validateAndSanitisePath(includePath, PATHS_PROPERTY, configFile, logger));
|
||||
}
|
||||
}
|
||||
const packs = parsePacks(parsedYAML[PACKS_PROPERTY], languages, configFile);
|
||||
const packs = parsePacks((_a = parsedYAML[PACKS_PROPERTY], (_a !== null && _a !== void 0 ? _a : {})), languages, configFile);
|
||||
return {
|
||||
languages,
|
||||
queries,
|
||||
|
|
@ -550,9 +551,6 @@ const PACK_IDENTIFIER_PATTERN = (function () {
|
|||
// Exported for testing
|
||||
function parsePacks(packsByLanguage, languages, configFile) {
|
||||
const packs = {};
|
||||
if (!packsByLanguage) {
|
||||
return packs;
|
||||
}
|
||||
if (Array.isArray(packsByLanguage)) {
|
||||
if (languages.length === 1) {
|
||||
// single language analysis, so language is implicit
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -999,7 +999,11 @@ async function loadConfig(
|
|||
}
|
||||
}
|
||||
|
||||
const packs = parsePacks(parsedYAML[PACKS_PROPERTY], languages, configFile);
|
||||
const packs = parsePacks(
|
||||
parsedYAML[PACKS_PROPERTY] ?? {},
|
||||
languages,
|
||||
configFile
|
||||
);
|
||||
|
||||
return {
|
||||
languages,
|
||||
|
|
@ -1029,16 +1033,12 @@ const PACK_IDENTIFIER_PATTERN = (function () {
|
|||
|
||||
// Exported for testing
|
||||
export function parsePacks(
|
||||
packsByLanguage: string[] | Record<string, string[]> | undefined,
|
||||
packsByLanguage: string[] | Record<string, string[]>,
|
||||
languages: Language[],
|
||||
configFile: string
|
||||
): Packs {
|
||||
const packs = {};
|
||||
|
||||
if (!packsByLanguage) {
|
||||
return packs;
|
||||
}
|
||||
|
||||
if (Array.isArray(packsByLanguage)) {
|
||||
if (languages.length === 1) {
|
||||
// single language analysis, so language is implicit
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue