feat(release): configure github api endpoint via environment variables

This commit is contained in:
Christoph Witzko 2015-02-04 23:31:56 +01:00
parent eb470712d7
commit 7380d586ee
2 changed files with 14 additions and 6 deletions

View File

@ -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
}
})

View File

@ -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),