aboutsummaryrefslogtreecommitdiff
path: root/bin/checkPeople.js
blob: 60527b951892e39d063f91668240fad664f2177d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const fs = require("fs");

const PEOPLE_PATH = "./people.json";

const [actor] = process.argv.slice(2);

console.log(`Triggered by ${actor}`);

if (!fs.existsSync(PEOPLE_PATH)) {
    throw "No people file found";
}

let people;
try {
    people = JSON.parse(fs.readFileSync(PEOPLE_PATH));
} catch (err) {
    throw "Could not read people.json as JSON";
}

const person = people.find(person => person.github === actor);
if (!person) {
    throw `${actor} isn't in people.json!`;
}

if (!(person.entries && person.entries.length > 0)) {
    throw `${actor} is missing entries!`;
}

console.log("Checked!");