diff options
author | funemy | 2022-10-25 07:14:52 +0000 |
---|---|---|
committer | funemy | 2022-10-25 07:14:52 +0000 |
commit | 998ef837b43203319397f191036a97a5adc42220 (patch) | |
tree | 920558bd60d282c663fd2da1cd4144cac1849a1d /bin | |
parent | fdac6c60e115297a58f5b81da0c4b7f18ac758f2 (diff) | |
parent | ce7544a6db594f7d3dfad0d7dc65d01515e57ad6 (diff) |
Merge branch 'main' of github.com:braxtonhall/fib
Diffstat (limited to 'bin')
-rw-r--r-- | bin/checkPeople.js | 36 |
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!"); |