Last active
June 7, 2018 11:50
-
-
Save efueyo/56ff086dd2693c4b27443b362704da9f to your computer and use it in GitHub Desktop.
Download Titles from Github Repo Issues
This file contains hidden or 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
| const Promise = require('bluebird') | |
| const fs = require('fs') | |
| const octokit = require('@octokit/rest')() | |
| octokit.authenticate({ | |
| type: 'basic', | |
| username: 'USER', | |
| password: 'PASS', | |
| }) | |
| function handleGithubResponse(response, filename) { | |
| const data = response.data | |
| data.filter( | |
| issue => !issue.pull_request | |
| ).forEach( | |
| issue => fs.appendFileSync(`${filename}`, `${issue.title}\n`) | |
| ) | |
| } | |
| async function getIssueTitles({owner, repo, filename}) { | |
| let response = await octokit.issues.getForRepo({ | |
| owner, repo, per_page: 100, state: 'all' | |
| }) | |
| handleGithubResponse(response, filename) | |
| while (octokit.hasNextPage(response)) { | |
| response = await octokit.getNextPage(response) | |
| handleGithubResponse(response, filename) | |
| } | |
| } | |
| const repos = [ | |
| { | |
| owner: 'facebook', | |
| repo: 'react', | |
| filename: 'react-issues.txt', | |
| }, { | |
| owner: 'vuejs', | |
| repo: 'vue', | |
| filename: 'vue-issues.txt', | |
| }, { | |
| owner: 'angular', | |
| repo: 'angular', | |
| filename: 'angular-issues.txt', | |
| }, | |
| ] | |
| Promise.mapSeries(repos, getIssueTitles) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment