Use nullish conversion for packs

Slightly simplifies the `parsePacks` function.
This commit is contained in:
Andrew Eisenberg 2021-06-09 13:18:27 -07:00
parent 49b2220f92
commit 96e7de35af
3 changed files with 9 additions and 11 deletions

View file

@ -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