Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix merge conflict for #17 by @kennethvandenberghe ❤️
- Loading branch information
Showing
3 changed files
with
77 additions
and
78 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 |
---|---|---|
@@ -1,44 +1,36 @@ | ||
// This helper goes and fetches Good First Issues | ||
// This module expects a search query which is just a standard GitHub search query. These queries should not include sort or order, since those are defined in the function. | ||
const chalk = require('chalk') | ||
|
||
const octokit = require('@octokit/rest')({ | ||
timeout: 0, // 0 means no request timeout | ||
headers: { | ||
accept: 'application/vnd.github.v3+json', | ||
'user-agent': 'octokit/rest.js v1.2.3' // v1.2.3 will be current version | ||
}, | ||
} | ||
}) | ||
|
||
// GitHub search parameters for the Node.js org | ||
var sort = 'updated' | ||
var order = 'desc' | ||
|
||
function search (q, cb) { | ||
octokit.search.issues({q, sort, order}, (error, result) => { | ||
if(error) throw error | ||
if(result.data.items.length === 0) { | ||
console.log(chalk.yellow('No issues were found')) | ||
process.exit(0) | ||
} | ||
var data = result.data.items.map(issue => { | ||
return data = { | ||
title: issue.title, | ||
pr: issue.number, | ||
labels: issue.labels, | ||
state: issue.state, | ||
repo: issue.repository_url, | ||
url: issue.html_url, | ||
assignee: issue.assignee, | ||
assignees: issue.assignees, | ||
locked: issue.locked | ||
function search(q) { | ||
return octokit.search.issues({ q, sort, order }).then(({ data }) => { | ||
return data.items.reduce((acc, item) => { | ||
if (item.assignee === null && item.locked !== true) { | ||
return acc.concat({ | ||
title: item.title, | ||
pr: item.number, | ||
labels: item.labels, | ||
state: item.state, | ||
repo: item.repository_url, | ||
url: item.html_url, | ||
assignee: item.assignee, | ||
assignees: item.assignees, | ||
locked: item.locked | ||
}) | ||
} | ||
}) | ||
|
||
var issues = data.filter(issue => issue.assignee === null && issue.locked !== true) | ||
|
||
cb(null, issues) | ||
return acc | ||
}, []) | ||
}) | ||
} | ||
} | ||
|
||
module.exports = search | ||
module.exports = search |
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