Skip to content

Commit

Permalink
feat(post): custom release note generation
Browse files Browse the repository at this point in the history
  • Loading branch information
boennemann committed Apr 24, 2015
1 parent 3369f31 commit 323b5d5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bin/semantic-release.js
Expand Up @@ -68,7 +68,7 @@ if (~argv._.indexOf('pre')) {
}

if (~argv._.indexOf('post')) {
require('../src/post')(argv, efh(function () {
require('../src/post')(argv, plugins, efh(function () {
// see src/restart.js
if (npmArgv['semantic-release-rerun']) {
console.log('Everything is alright :) npm will now print an error message that you can safely ignore.')
Expand Down
17 changes: 17 additions & 0 deletions lib/release-notes.js
@@ -0,0 +1,17 @@
'use strict'

var readFile = require('fs').readFileSync

var changelog = require('conventional-changelog')
var parseUrl = require('github-url-from-git')

module.exports = function (cb) {
var pkg = JSON.parse(readFile('./package.json'))
var repository = pkg.repository ? parseUrl(pkg.repository.url) : null

changelog({
version: pkg.version,
repository: repository,
file: false
}, cb)
}
12 changes: 4 additions & 8 deletions src/post.js
Expand Up @@ -3,20 +3,20 @@
var readFile = require('fs').readFileSync
var url = require('url')

var changelog = require('conventional-changelog')
var gitHead = require('git-head')
var GitHubApi = require('github')
var parseSlug = require('parse-github-repo-url')
var parseUrl = require('github-url-from-git')

var efh = require('../lib/error').efh

module.exports = function (options, cb) {
module.exports = function (options, plugins, 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 notesGenerator = require(plugins.notes || '../lib/release-notes')

var config = options['github-url'] ? url.parse(options['github-url']) : {}

var github = new GitHubApi({
Expand All @@ -26,11 +26,7 @@ module.exports = function (options, cb) {
host: config.hostname
})

changelog({
version: pkg.version,
repository: parseUrl(repository),
file: false
}, efh(cb)(function (log) {
notesGenerator(efh(cb)(function (log) {
gitHead(efh(cb)(function (hash) {
var ghRepo = parseSlug(repository)
var release = {
Expand Down

0 comments on commit 323b5d5

Please sign in to comment.