mirror of
https://github.com/all-contributors/cli.git
synced 2025-01-10 05:56:29 +00:00
a879de2a7f
* Add editor config * Fix non-http prepended urls * Remove editorconfig * Use startsWith and shorthand operator
25 lines
579 B
JavaScript
25 lines
579 B
JavaScript
'use strict';
|
|
|
|
var pify = require('pify');
|
|
var request = pify(require('request'));
|
|
|
|
module.exports = function getUserInfo(username) {
|
|
return request.get({
|
|
url: 'https://api.github.com/users/' + username,
|
|
headers: {
|
|
'User-Agent': 'request'
|
|
}
|
|
})
|
|
.then(res => {
|
|
var body = JSON.parse(res.body);
|
|
var profile = body.blog || body.html_url;
|
|
profile = profile.startsWith('http') ? profile : 'http://' + profile;
|
|
|
|
return {
|
|
login: body.login,
|
|
name: body.name || username,
|
|
avatar_url: body.avatar_url,
|
|
profile
|
|
};
|
|
});
|
|
};
|