Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions scripts/modify-board-data/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ import { execSync } from 'child_process';

// Tier mapping
function mapTier(tiers, tier) {
return tiers[upperFirstLetters(tier)].id;
try {
return tiers[upperFirstLetters(tier)].id;
} catch {
return undefined;
}
}

async function viewDiff() {
Expand All @@ -59,17 +63,17 @@ function findOfficer(boardOfficers, name) {
async function editOfficer(officers, tiers) {
const lookfor = await readInput('What officer do you want to edit/add? ');
let officer = await findOfficer(officers, lookfor);
let ifNew = false;
if (!officer) {
ifNew = true;
console.log('Unable to locate ', lookfor, '. Making new officer');

officer = {
fullName: upperFirstLetters(lookfor),
picture: '',
discord: '',
positions: {},
discord: '',
};

officers.push(officer);
}

// Gaballa, why are you switching between string literal and template literal?
Expand Down Expand Up @@ -137,6 +141,14 @@ async function editOfficer(officers, tiers) {
break;
}

const tier = mapTier(tiers, title);
if (tier == undefined) {
console.log(
'Bad Title, please check the spelling and try again [Can be found in src/lib/public/board/data/tiers]'
);
continue;
}

officer.positions[term].push({
title: upperFirstLetters(title),
tier: mapTier(tiers, title),
Expand All @@ -150,6 +162,9 @@ async function editOfficer(officers, tiers) {
while (true) {
const confirmation = (await readInput('Are you okay with these changes? [y/n] ')).toLowerCase();
if (confirmation === 'yes' || confirmation === 'y') {
if (ifNew) {
officers.push(officer);
}
writeToCopy(JSON.stringify(officers, null, 2));
return officers;
}
Expand Down
1 change: 1 addition & 0 deletions selected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ARCHITECTURE.md
Loading
Loading