Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ This way your contributors will be formatted in a table with their photos.

The table strategy accepts the following parameters:

- `image-size` - Number - size of the user's avatars
- `imagesize` - Number - size of the user's avatars
- `format` - Enum - `MARKDOWN` or `HTML`. Default == `HTML`
- `showlogin` - Boolean, indicates whether the login of the contributor should be shown in the table. Default == `false`
- `columns-count` - Number - number of columns for the table
Expand Down
2 changes: 1 addition & 1 deletion bin/githubcontrib
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var logResults = function (obj) {

console.log( wantsJSON ? JSON.stringify(obj) : obj );
};
var logErrors = function (obj) { console.error(obj); };
var logErrors = function (obj) { console.error(obj); process.exit(1); };


/**
Expand Down
21 changes: 16 additions & 5 deletions lib/githubLoader.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
"use strict";

var q = require('q'),
https = require('https'),
merge = require('merge');
var q = require('q'),
https = require('https'),
merge = require('merge'),
sprintf = require('sprintf-js').sprintf;

var formatAPIError = function (response, result) {
return sprintf('GitHubAPIError: statusCode=%d, statusMessage=%s,\nmessage=%s,\ndocumentation_url=%s',
response.statusCode, response.statusMessage,
result.message, result.documentation_url);
};

module.exports = function GitHubAPI(options) {

Expand All @@ -18,7 +25,7 @@ module.exports = function GitHubAPI(options) {
function loadAllPages( path, headers ) {
var jsonResponse = '', result = [], deferred = q.defer();
var concatData = function (chunk) { jsonResponse += chunk; };
var reject = function (e) { console.log(e); deferred.reject(e); };
var reject = function (e) { deferred.reject(e); };
var requestOptions = {
port : 443,
method : 'GET',
Expand Down Expand Up @@ -46,6 +53,11 @@ module.exports = function GitHubAPI(options) {
response.on('error', reject);
response.on('data', concatData);
response.on('end', function () {
if (response.statusCode !== 200) {
var thisResult = JSON.parse(jsonResponse);
reject(formatAPIError(response, thisResult));
return;
}
result = result.concat(JSON.parse(jsonResponse));

// Do we have more than 1 page of data ?
Expand All @@ -54,7 +66,6 @@ module.exports = function GitHubAPI(options) {
loadPage(page);
return;
}

deferred.resolve(result);
cleanup();
});
Expand Down
70 changes: 61 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"homepage": "https://github.com/mgechev/github-contributors-list",
"dependencies": {
"marked": "^0.8.0",
"marked": "^4.0.18",
"merge": "^2.1.1",
"minimist": "^1.2.0",
"q": "^1.5.1",
Expand Down