feat(pre): add option to provide own commit message analyzer

This commit is contained in:
Stephan Bönnemann
2015-04-22 17:15:10 +02:00
parent 29469e0b8a
commit e445effdcf
6 changed files with 53 additions and 31 deletions
+8 -3
View File
@@ -4,16 +4,21 @@ var fs = require('fs')
var semver = require('semver')
var type = require('../lib/type')
var getCommits = require('../lib/commits')
var npmInfo = require('../lib/npm-info')
var efh = require('../lib/error').efh
module.exports = function (options, cb) {
module.exports = function (options, plugins, cb) {
var path = './package.json'
var pkg = JSON.parse(fs.readFileSync(path))
if (!pkg.name) return cb(new Error('Package must have a name'))
npmInfo(pkg.name, efh(cb)(function (res) {
type(res.gitHead, efh(cb)(function (type) {
getCommits(res.gitHead, efh(cb)(function (commits) {
var analyzer = require(plugins.analyzer || '../lib/analyzer')
var type = analyzer(commits)
if (!type) return cb(null, null)
pkg.version = !res.version ? '1.0.0' : semver.inc(res.version, type)
if (!options.debug) fs.writeFileSync(path, JSON.stringify(pkg, null, 2))