feat(pre): add option to provide own commit message analyzer
This commit is contained in:
+8
-3
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user