Skip to content

Commit

Permalink
Merge pull request #6 from benjaminbwright/5-config-file-properties-d…
Browse files Browse the repository at this point in the history
…ont-correctly-filter-the-repos

Uses config data for minStars, minWatchers and forks to filter repos …
  • Loading branch information
benjaminbwright committed Nov 3, 2022
2 parents 485c6c1 + 2653589 commit 62d6c1f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/repos.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,22 @@ export const getRepos = async (user, configData) => {
// let { data: user } = await axios.get(`https://api.github.com/users/${user}/repos?per_page=1001`)
let { data: repos } = await axios.get(`https://api.github.com/users/${user}/repos?per_page=1001`)
// console.log(repos)
repos = notForks(repos);
const watched = watchedOnly(repos);
if (!configData.forks) {
repos = notForks(repos);
}
const watched = minWatchersOnly(repos, configData.minWatchers);
// don't include forks
const starred = starsOnly(repos)
const starred = minStarsOnly(repos, configData.minStars)
// only include repose with active issues
const withIssues = openIssues(repos);
const combinedRepos = [
let combinedRepos = [
...new Set([
...starred,
...watched,
...withIssues
])
]


cloneRepos(combinedRepos, getLocalDirectories("./"), configData)
}
Expand All @@ -42,14 +45,14 @@ export const getRepos = async (user, configData) => {
* @param {Array} repos a list of repos
* @returns {Array} repos with a stargazers
*/
export const starsOnly = repos => repos.filter(({ stargazers_count }) => stargazers_count > 0)
export const minStarsOnly = (repos, minStars) => repos.filter(({ stargazers_count }) => stargazers_count >= minStars)

/**
* Returns a list of github repos that have been watched
* @param {Array} repos a list of repos
* @returns {Array}
*/
export const watchedOnly = repos => repos.filter(({ watchers_count }) => watchers_count > 0)
export const minWatchersOnly = (repos, minWatchers) => repos.filter(({ watchers_count }) => watchers_count >= minWatchers)

/**
* Returns a list of github repos with open issues
Expand Down

0 comments on commit 62d6c1f

Please sign in to comment.