From 7380d586ee0f0e80e2dd8341a849cf64f58dc954 Mon Sep 17 00:00:00 2001 From: Christoph Witzko Date: Wed, 4 Feb 2015 23:31:56 +0100 Subject: [PATCH] feat(release): configure github api endpoint via environment variables --- bin/semantic-release | 6 ++++-- src/post.js | 14 ++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/bin/semantic-release b/bin/semantic-release index 67fa9ccd..daf40e30 100755 --- a/bin/semantic-release +++ b/bin/semantic-release @@ -11,10 +11,12 @@ var argv = minimist(process.argv.slice(2), { alias: { d: 'debug', dry: 'debug', - t: 'token' + t: 'token', + g: 'github-url' }, default: { - token: process.env.GH_TOKEN || process.env.TOKEN || process.env.GITHUB_TOKEN + token: process.env.GH_TOKEN || process.env.TOKEN || process.env.GITHUB_TOKEN, + 'github-url': process.env.GH_URL } }) diff --git a/src/post.js b/src/post.js index 47932365..b97376e0 100644 --- a/src/post.js +++ b/src/post.js @@ -2,6 +2,7 @@ var exec = require('child_process').exec var readFile = require('fs').readFileSync +var url = require('url') var changelog = require('conventional-changelog') var GitHubApi = require('github') @@ -10,16 +11,21 @@ var parseUrl = require('github-url-from-git') var efh = require('../lib/error').efh -var github = new GitHubApi({ - version: '3.0.0' -}) - module.exports = function (options, cb) { var pkg = JSON.parse(readFile('./package.json')) var repository = pkg.repository ? pkg.repository.url : null if (!repository) return cb(new Error('Package must have a repository')) + var config = options['github-url'] ? url.parse(options['github-url']) : {} + + var github = new GitHubApi({ + version: '3.0.0', + port: config.port, + protocol: (config.protocol || '').split(':')[0] || null, + host: config.hostname + }) + changelog({ version: pkg.version, repository: parseUrl(repository),