From aa56ae6ef3082fe962d9fd0f99099c84f0c17902 Mon Sep 17 00:00:00 2001 From: Steve Mao Date: Sat, 13 Feb 2016 15:36:56 +1100 Subject: [PATCH] feat(debug): add options.debug function --- lib/get-defaults.js | 7 +++++-- readme.md | 12 +++++++++++- test/test.js | 9 +++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/lib/get-defaults.js b/lib/get-defaults.js index 6554541..de30199 100644 --- a/lib/get-defaults.js +++ b/lib/get-defaults.js @@ -37,7 +37,7 @@ function getDefaults(options, context, gitRawCommitsOpts, parserOpts, writerOpts }, append: false, releaseCount: 1, - warn: function() {}, + debug: function() {}, transform: function(commit, cb) { if (_.isString(commit.gitTags)) { var match = rtag.exec(commit.gitTags); @@ -56,6 +56,8 @@ function getDefaults(options, context, gitRawCommitsOpts, parserOpts, writerOpts } }, options); + options.warn = options.warn || options.debug; + if (options.config) { if (_.isFunction(options.config)) { configPromise = Q.nfcall(options.config); @@ -191,7 +193,8 @@ function getDefaults(options, context, gitRawCommitsOpts, parserOpts, writerOpts gitRawCommitsOpts = _.assign({ format: '%B%n-hash-%n%H%n-gitTags-%n%d%n-committerDate-%n%ci', from: fromTag, - merges: false + merges: false, + debug: options.debug }, config.gitRawCommitsOpts, gitRawCommitsOpts diff --git a/readme.md b/readme.md index f4ca98e..5318d66 100644 --- a/readme.md +++ b/readme.md @@ -66,10 +66,16 @@ Type: `number` Default: `1` How many releases of changelog you want to generate. It counts from the upcoming release. Useful when you forgot to generate any previous changelog. Set to `0` to regenerate all. -##### warn +##### debug Type: `function` Default: `function() {}` +A debug function. EG: `console.debug.bind(console)` + +##### warn + +Type: `function` Default: `options.debug` + A warn function. EG: `grunt.verbose.writeln` ##### transform @@ -162,6 +168,10 @@ Default: based on `options.releaseCount`. Default: `true` if `options.append` is truthy. +##### debug + +Type: `function` Default: `options.debug` + #### parserOpts See the [conventional-commits-parser](https://github.com/stevemao/conventional-commits-parser) docs. diff --git a/test/test.js b/test/test.js index 5b3096c..2ec4426 100644 --- a/test/test.js +++ b/test/test.js @@ -135,6 +135,15 @@ describe('conventionalChangelogCore', function() { })); }); + it('should spit out some debug info', function(done) { + conventionalChangelogCore({ + debug: function(cmd) { + expect(cmd).to.equal('Your git-log command is:\ngit log --format="%B%n-hash-%n%H%n-gitTags-%n%d%n-committerDate-%n%ci%n------------------------ >8 ------------------------" "v0.1.0..HEAD" --no-merges'); + done(); + } + }); + }); + it('should load package.json for data', function(done) { conventionalChangelogCore({ pkg: {