All files / util github.js

100% Statements 8/8
100% Branches 6/6
100% Functions 2/2
100% Lines 8/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28        5x 2x 3x 1x         3x           3x 1x         3x      
import GitHubAPI from 'github';
 
export default class GitHub {
  constructor(authToken) {
    if (authToken) {
      this.token = authToken;
    } else if (process.env.GITHUB_TOKEN) {
      this.token = process.env.GITHUB_TOKEN;
    }
  }
 
  getGitHub() {
    const github = new GitHubAPI({
      protocol: 'https',
      headers: {
        'user-agent': 'Electron Forge',
      },
    });
    if (this.token) {
      github.authenticate({
        type: 'token',
        token: this.token,
      });
    }
    return github;
  }
}