22 lines
508 B
JavaScript
22 lines
508 B
JavaScript
/* eslint no-console: 0 */
|
|
import Octokat from 'octokat';
|
|
|
|
function usageError() {
|
|
console.error('You must provide a github repo in the form of "owner/repo"');
|
|
process.exit(1);
|
|
}
|
|
|
|
export default function(repo) {
|
|
if (typeof repo !== 'string' || repo.length === 0) usageError();
|
|
const settings = {
|
|
token: process.env.GITHUB_ACCESS_TOKEN,
|
|
};
|
|
|
|
const octo = new Octokat(settings);
|
|
const [owner, name] = repo.split('/');
|
|
|
|
if (!owner || !name) usageError();
|
|
|
|
return octo.repos(owner, name);
|
|
}
|