A Node.JS module to retrieve a Github user's git contributions by programming language
See examples in /examples
Install
npm install --save github-lang-getter
Import
const langGetter = require('github-lang-getter');
Return the language makeup of a user's repositories, in bytes
The numbers returned by this method reflect the number of bytes committed by all contributors.
var visibility = 'all'; // can be all, public, or private
var token = 'YOUR-ACCESS-TOKEN'; // https://github.com/settings/tokens
langGetter.getRepoLanguages(visibility, token).then((result) => {
console.log(result);
}).catch((err) => {
console.log(err);
});
Return the language makeup of a user's commits, in bytes
The numbers returned by this method reflect the number of bytes only committed by the user.
var visibility = 'all'; // can be all, public, or private
var token = 'YOUR-ACCESS-TOKEN'; // https://github.com/settings/tokens
langGetter.getCommitLanguages(visibility, token).then((result) => {
console.log(result);
}).catch((err) => {
console.log(err);
});
Both of the above method will output a result similar to the following:
{
CSS: 2917838,
HTML: 2198373,
JavaScript: 19115215
}
Mocha tests are located in /test
To run the tests, create a .env file at the root directory with contents like the following:
GITHUB_ACCESS_TOKEN=YOUR-ACCESS-TOKEN
Run the following commands
npm install
npm test
Bug fixes and new features are encouraged, feel free to fork and make a pull request.
- Follow the ESLint rules set in .eslintrc.js
- Add Mocha tests for new functionality
- Improve API calls to prevent Github rate limit errors
- Find a way to exclude bytes in files that are a result of build processes
- Add methods to get language stats by Github username (only for public repos)