Socket
Socket
Sign inDemoInstall

github-contributors

Package Overview
Dependencies
46
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.0 to 0.4.0

80

index.js
'use strict';
var extend = require('extend-shallow');
var pad = require('right-pad-values');
var mdu = require('markdown-utils');
var GitHub = require('github-base');
var format = {};
var format = require('format-people');
module.exports = function contributors(repo, options, cb) {
if (typeof repo !== 'string') {
throw new TypeError('github-contributors expects repo to be a string.');
}
if (typeof options === 'function') {

@@ -20,69 +13,16 @@ cb = options;

if (typeof cb !== 'function') {
throw new TypeError('github-contributors expects callback to be a function.');
throw new TypeError('expected callback to be a function.');
}
if (typeof repo !== 'string') {
cb(new TypeError('expected repo to be a string.'));
return;
}
var opts = extend({format: 'noop'}, options);
var github = new GitHub(opts);
var method = options && options.format || 'noop';
var github = new GitHub(options);
github.getAll('/repos/:repo/contributors', {repo: repo}, function (err, res) {
github.paged(`/repos/:${repo}/contributors`, function(err, data) {
if (err) return cb(err);
if (!format.hasOwnProperty(opts.format)) {
cb(new Error('github-contributors does not have format: ' + opts.format));
return;
}
cb(null, format[opts.format](res));
cb(null, format(data, options));
});
};
format.noop = function noop(arr) {
return arr;
};
format.table = function table(arr) {
arr = pad(arr, 'contributions');
var res = '| **Commits** | **Contributor**<br/> | ';
res += '\n';
res += '| --- | --- | ';
res += '\n';
arr.forEach(function (person) {
res += '| ';
res += person.contributions;
res += ' | ';
res += mdu.link(person.login, person.html_url);
res += ' | ';
res += '\n';
});
return res;
};
format.list = function list(arr) {
arr = pad(arr, 'contributions');
var res = '**Commits** / **Contributor**\n';
arr.forEach(function (person) {
res += '+ ';
res += person.contributions;
res += ' ';
res += mdu.link(person.login, person.html_url);
res += '\n';
});
return res;
};
format.aligned = function aligned(arr) {
arr = pad(arr, 'contributions');
var res = '```bash\n';
res += 'COMMITS / CONTRIBUTOR\n';
res += '------- | -----------\n';
arr.forEach(function (person) {
res += person.contributions;
res += ' ';
res += person.login;
res += '\n';
});
res += '```\n';
return res;
};

17

package.json
{
"name": "github-contributors",
"description": "Generate a markdown or JSON list of contributors for a project using the GitHub API.",
"version": "0.3.0",
"version": "0.4.0",
"homepage": "https://github.com/jonschlinkert/github-contributors",

@@ -13,5 +13,3 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

"files": [
"index.js",
"LICENSE",
"README.md"
"index.js"
],

@@ -26,11 +24,10 @@ "main": "index.js",

"dependencies": {
"extend-shallow": "^2.0.1",
"github-base": "^0.4.1",
"markdown-utils": "^0.7.3",
"right-pad-values": "^0.3.1"
"format-people": "^0.1.1",
"github-base": "^0.5.0"
},
"devDependencies": {
"data-store": "^0.16.1",
"extend-shallow": "^2.0.1",
"gulp-format-md": "^0.1.10",
"mocha": "^3.0.2",
"should": "^11.1.0"
"mocha": "^3.0.2"
},

@@ -37,0 +34,0 @@ "keywords": [

# github-contributors [![NPM version](https://img.shields.io/npm/v/github-contributors.svg?style=flat)](https://www.npmjs.com/package/github-contributors) [![NPM downloads](https://img.shields.io/npm/dm/github-contributors.svg?style=flat)](https://npmjs.org/package/github-contributors) [![Build Status](https://img.shields.io/travis/jonschlinkert/github-contributors.svg?style=flat)](https://travis-ci.org/jonschlinkert/github-contributors)
Generate a markdown or JSON list of contributors for a project using the GitHub API.
> Generate a markdown or JSON list of contributors for a project using the GitHub API.

@@ -127,3 +127,3 @@ ## Install

* [get-pkgs](https://www.npmjs.com/package/get-pkgs): Get the package.json for an array of repos from the npm registry, optionally filtering properties… [more](https://github.com/jonschlinkert/get-pkgs) | [homepage](https://github.com/jonschlinkert/get-pkgs "Get the package.json for an array of repos from the npm registry, optionally filtering properties using glob patterns.")
* [github-base](https://www.npmjs.com/package/github-base): Base methods for creating node.js apps that work with the GitHub API. | [homepage](https://github.com/jonschlinkert/github-base "Base methods for creating node.js apps that work with the GitHub API.")
* [github-base](https://www.npmjs.com/package/github-base): JavaScript wrapper that greatly simplifies working with GitHub's API. | [homepage](https://github.com/jonschlinkert/github-base "JavaScript wrapper that greatly simplifies working with GitHub's API.")

@@ -166,2 +166,2 @@ ### Contributing

_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.1.30, on August 21, 2016._
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.1.30, on September 09, 2016._
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc