Skip to content

Commit 8a003f2

Browse files
committed
Merge pull request #4 from kasperisager/master
Add support for custom GitHub API domains (Enterprise et. al.).
2 parents 880b2da + 8ed3f8b commit 8a003f2

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

lib/handler.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
1-
var GithubApi = require('github')
1+
var url = require('url')
2+
, GithubApi = require('github')
23
, debug = require('debug')('strider-github-status')
34

5+
var GITHUB_DOMAIN = process.env.PLUGIN_GITHUB_API_DOMAIN
6+
, GITHUB_API_ENDPOINT = process.env.PLUGIN_GITHUB_API_ENDPOINT;
7+
8+
var config = {
9+
version: '3.0.0'
10+
};
11+
12+
if (GITHUB_DOMAIN) {
13+
config.host = url.parse(GITHUB_DOMAIN).host;
14+
}
15+
16+
if (GITHUB_API_ENDPOINT) {
17+
config.pathPrefix = url.parse(GITHUB_API_ENDPOINT).path;
18+
}
19+
420
module.exports = function (token, url, data, status, description) {
521
debug('Setting status', token, url, data, status, description)
6-
var github = new GithubApi({ version: '3.0.0', })
22+
var github = new GithubApi(config)
723
github.authenticate({
824
type: 'oauth',
925
token: token

0 commit comments

Comments
 (0)