aboutsummaryrefslogtreecommitdiff
path: root/bin/checkPeople.js
diff options
context:
space:
mode:
authorBraxton Hall2022-10-24 19:38:20 +0000
committerGitHub2022-10-24 19:38:20 +0000
commit59e81fca4d450c71f10722792d36abf1b721caff (patch)
treebbc0837d1a492e1fb946c9fa6a4e6aea66b28305 /bin/checkPeople.js
parent0aa0d695f8fef33b02cbf04fbd6825bd2cbc6de1 (diff)
parenta139a04ba0a5de1c36044e3dae1c6833193d2bea (diff)
Merge branch 'main' into main
Diffstat (limited to 'bin/checkPeople.js')
-rw-r--r--bin/checkPeople.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/bin/checkPeople.js b/bin/checkPeople.js
new file mode 100644
index 0000000..3c564a4
--- /dev/null
+++ b/bin/checkPeople.js
@@ -0,0 +1,36 @@
+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!`;
+}
+
+for (const entry of person.entries) {
+ const {link} = entry;
+ if (!(link.startsWith("http") || fs.existsSync(link))) {
+ throw `${link} not found!`;
+ }
+}
+
+console.log("Checked!");