Skip to content

Extracted GitHub client for reuseability #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions lib/github-client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict'

const GitHub = require('github')

const githubClient = new GitHub({
version: '3.0.0',
protocol: 'https',
host: 'api.github.com',
timeout: 5 * 1000,
headers: {
'user-agent': 'Node.js GitHub Bot v1.0-beta'
}
})

githubClient.authenticate({
type: 'oauth',
token: process.env.GITHUB_TOKEN
})

module.exports = githubClient
17 changes: 2 additions & 15 deletions lib/pollTravis.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
'use strict'

const GitHub = require('github')
const Travis = require('travis-ci')

const githubClient = require('./github-client')

const travisClient = new Travis({
version: '2.0.0',
access_token: process.env.TRAVIS_CI_TOKEN
})
const githubClient = new GitHub({
version: '3.0.0',
protocol: 'https',
host: 'api.github.com',
timeout: 5 * 1000,
headers: {
'user-agent': 'Node.js GitHub Bot v1.0-beta'
}
})

githubClient.authenticate({
type: 'oauth',
token: process.env.GITHUB_TOKEN
})

exports.pollThenStatus = pollByCommitThenStatus

Expand Down