Skip to content

Instantly share code, notes, and snippets.

@erikvold
Created September 15, 2011 04:21
Show Gist options
  • Save erikvold/1218527 to your computer and use it in GitHub Desktop.
Save erikvold/1218527 to your computer and use it in GitHub Desktop.
a quick script I wrote to export GH-issues to json files..
var sys = require("sys");
var fs = require('fs');
var GitHubApi = require("./github").GitHubApi;
var githubAPI = new GitHubApi(true);
var issuesAPI = githubAPI.getIssueApi();
username = "repoUsername";
repo = "repoName";
var i = 0;
["open", "closed"].forEach(function(state) {
issuesAPI.getList(username, repo, state, function(err, issues) {
issues.forEach(function(issue) {
var getComments = function(err, comments) {
// limit exceeded bs
if (err) {
setTimeout(function() {
issuesAPI.getComments(username, repo, issue.number, getComments);
}, 2500 + (issue.number * 15));
return;
}
issue.comments = comments;
JSON.parse(JSON.stringify(issue));
console.log(++i);
// write data to file
fs.writeFile(issue.number+".json", JSON.stringify(issue), function(err) {
if(err) {
sys.puts(err);
} else {
sys.puts("Issue "+ issue.number +" was saved!");
}
});
};
issuesAPI.getComments(username, repo, issue.number, getComments);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment