UNPKG

758 BJavaScriptView Raw
1/*******************************
2 GitHub Login
3*******************************/
4/*
5 Logs into GitHub using OAuth
6*/
7
8const
9 fs = require('fs'),
10 path = require('path'),
11 GithubAPI = require('@octokit/rest'),
12
13 // stores oauth info for GitHub API
14 oAuth = fs.existsSync(path.join(__dirname, './oauth.js'))
15 ? require('./oauth.js') // eslint-disable-line import/extensions
16 : false
17;
18
19if (!oAuth) {
20 console.error('Must add oauth token for GitHub in tasks/config/admin/oauth.js');
21}
22
23let github = new GithubAPI({
24 version: '3.0.0',
25 debug: true,
26 protocol: 'https',
27 timeout: 5000,
28});
29
30github.authenticate({
31 type: 'oauth',
32 token: oAuth.token,
33});
34
35module.exports = github;