Handle possibility of empty positions
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Amy 2022-09-02 01:02:36 -04:00
parent d6b0767326
commit 0b16c00780
1 changed files with 11 additions and 10 deletions

View File

@ -104,10 +104,6 @@ async function getExecNamePosPairs({
)}${year}))`,
});
if (searchEntries.length === 0) {
throw new Error(`No execs found for ${term} ${year}`);
}
// item.position might be an array if the member has more than one position
searchEntries.forEach((item) => {
if (typeof item.position === "string" && item.position in execPositions) {
@ -121,12 +117,17 @@ async function getExecNamePosPairs({
}
});
formattedExec = orderedExecPositions.map((position) => {
const fullName = execMembers[position];
const firstName = fullName.split(" ")[0].toLowerCase();
const lastName = fullName.split(" ")[1].toLowerCase();
return [`${firstName}-${lastName}`, position];
});
formattedExec = orderedExecPositions
.map((position) => {
const fullName = execMembers[position];
if (fullName == undefined) {
return null;
}
const firstName = fullName.split(" ")[0].toLowerCase();
const lastName = fullName.split(" ")[1].toLowerCase();
return [`${firstName}-${lastName}`, position];
})
.filter((pair) => pair != null) as [person: string, position: string][];
formattedExec = [...formattedExec, ["codey", "mascot"]];
} finally {