Refactor exclude list

This commit is contained in:
Julien Bisconti 2020-04-13 17:36:19 +02:00
parent f8a05b1335
commit d4ce2665e2
No known key found for this signature in database
GPG Key ID: 62772C6698F736CB
2 changed files with 18 additions and 6 deletions

View File

@ -1,4 +1,4 @@
{
"https://vimeo.com": "https://vimeo.com",
"https://travis-ci.org/veggiemonk/awesome-docker.svg": "https://travis-ci.org/veggiemonk/awesome-docker.svg"
}
[
"https://vimeo.com",
"https://travis-ci.org/veggiemonk/awesome-docker.svg"
]

View File

@ -136,6 +136,18 @@ const generate_GQL_query = (arr) =>
// };
// =============================================================
const exclude_length = exclude.length;
const exclude_from_list = (link) => {
let is_excluded = false;
for (let i = 0; i < exclude_length; i += 1) {
if (link.startsWith(exclude[i])) {
is_excluded = true;
break;
}
}
return is_excluded;
};
async function main() {
const has_error = {
show: false,
@ -145,8 +157,8 @@ async function main() {
};
const markdown = await fs.readFile(README, 'utf8');
let links = extract_all_links(markdown);
links = links.filter((l) => !(exclude[l] && l.startsWith(exclude[l]))); // exclude websites
links = links.filter((l) => !exclude_from_list(l)); // exclude websites
LOG.debug_string({ links });
const duplicates = find_duplicates(links);
if (duplicates.length > 0) {
has_error.show = true;