feat: add support for EXCLUDE_REPO env variable (#1299)
* Add support for EXCLUDE_REPO env variable * review * docs * refactor --------- Co-authored-by: Alexandr <qwerty541zxc@gmail.com>
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
const excludeRepositories = process.env.EXCLUDE_REPO
|
||||
? process.env.EXCLUDE_REPO.split(",")
|
||||
: [];
|
||||
|
||||
export { excludeRepositories };
|
||||
export default excludeRepositories;
|
||||
@@ -1,4 +1,5 @@
|
||||
// @ts-check
|
||||
|
||||
import axios from "axios";
|
||||
import * as dotenv from "dotenv";
|
||||
import githubUsernameRegex from "github-username-regex";
|
||||
@@ -11,6 +12,7 @@ import {
|
||||
request,
|
||||
wrapTextMultiline,
|
||||
} from "../common/utils.js";
|
||||
import excludeRepositories from "../common/excludeRepo.js";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
@@ -312,7 +314,8 @@ const fetchStats = async (
|
||||
stats.contributedTo = user.repositoriesContributedTo.totalCount;
|
||||
|
||||
// Retrieve stars while filtering out repositories to be hidden.
|
||||
let repoToHide = new Set(exclude_repo);
|
||||
const allExcludedRepos = [...exclude_repo, ...excludeRepositories];
|
||||
let repoToHide = new Set(allExcludedRepos);
|
||||
|
||||
stats.totalStars = user.repositories.nodes
|
||||
.filter((data) => {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// @ts-check
|
||||
|
||||
import { retryer } from "../common/retryer.js";
|
||||
import {
|
||||
CustomError,
|
||||
@@ -7,6 +8,7 @@ import {
|
||||
request,
|
||||
wrapTextMultiline,
|
||||
} from "../common/utils.js";
|
||||
import excludeRepositories from "../common/excludeRepo.js";
|
||||
|
||||
/**
|
||||
* @typedef {import("axios").AxiosRequestHeaders} AxiosRequestHeaders Axios request headers.
|
||||
@@ -99,11 +101,12 @@ const fetchTopLanguages = async (
|
||||
|
||||
let repoNodes = res.data.data.user.repositories.nodes;
|
||||
let repoToHide = {};
|
||||
const allExcludedRepos = [...exclude_repo, ...excludeRepositories];
|
||||
|
||||
// populate repoToHide map for quick lookup
|
||||
// while filtering out
|
||||
if (exclude_repo) {
|
||||
exclude_repo.forEach((repoName) => {
|
||||
if (allExcludedRepos) {
|
||||
allExcludedRepos.forEach((repoName) => {
|
||||
repoToHide[repoName] = true;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user