-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
45 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const fs = require('fs').promises; | ||
const core = require('@actions/core'); | ||
|
||
async function main() { | ||
let errors = false; | ||
const files = process.argv.slice(2); | ||
const res = await fetch( | ||
'https://raw.githubusercontent.com/2factorauth/frontend/master/data/categories.json', | ||
{ | ||
'accept': 'application/json', | ||
'user-agent': '2factorauth/twofactorauth +https://2fa.directory/bots', | ||
}); | ||
|
||
if (!res.ok) throw new Error('Unable to fetch categories'); | ||
|
||
const data = await res.json(); | ||
const allowed_categories = Object.keys(data); | ||
|
||
if (files) { | ||
for (const file of files) { | ||
const data = await fs.readFile(file, 'utf8'); | ||
const json = await JSON.parse(data); | ||
const entry = json[Object.keys(json)[0]]; | ||
const {categories} = entry; | ||
|
||
for (const category of categories || []) { | ||
if (!allowed_categories.includes(category)) { | ||
core.error(`${category} is not a valid category.`, {file}); | ||
errors = true; | ||
} | ||
} | ||
} | ||
} | ||
process.exit(+errors); | ||
} | ||
|
||
module.exports = main(); |
This file was deleted.
Oops, something went wrong.