feat(release): configure github api endpoint via environment variables
This commit is contained in:
parent
eb470712d7
commit
7380d586ee
@ -11,10 +11,12 @@ var argv = minimist(process.argv.slice(2), {
|
|||||||
alias: {
|
alias: {
|
||||||
d: 'debug',
|
d: 'debug',
|
||||||
dry: 'debug',
|
dry: 'debug',
|
||||||
t: 'token'
|
t: 'token',
|
||||||
|
g: 'github-url'
|
||||||
},
|
},
|
||||||
default: {
|
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
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
14
src/post.js
14
src/post.js
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
var exec = require('child_process').exec
|
var exec = require('child_process').exec
|
||||||
var readFile = require('fs').readFileSync
|
var readFile = require('fs').readFileSync
|
||||||
|
var url = require('url')
|
||||||
|
|
||||||
var changelog = require('conventional-changelog')
|
var changelog = require('conventional-changelog')
|
||||||
var GitHubApi = require('github')
|
var GitHubApi = require('github')
|
||||||
@ -10,16 +11,21 @@ var parseUrl = require('github-url-from-git')
|
|||||||
|
|
||||||
var efh = require('../lib/error').efh
|
var efh = require('../lib/error').efh
|
||||||
|
|
||||||
var github = new GitHubApi({
|
|
||||||
version: '3.0.0'
|
|
||||||
})
|
|
||||||
|
|
||||||
module.exports = function (options, cb) {
|
module.exports = function (options, cb) {
|
||||||
var pkg = JSON.parse(readFile('./package.json'))
|
var pkg = JSON.parse(readFile('./package.json'))
|
||||||
var repository = pkg.repository ? pkg.repository.url : null
|
var repository = pkg.repository ? pkg.repository.url : null
|
||||||
|
|
||||||
if (!repository) return cb(new Error('Package must have a repository'))
|
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({
|
changelog({
|
||||||
version: pkg.version,
|
version: pkg.version,
|
||||||
repository: parseUrl(repository),
|
repository: parseUrl(repository),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user