Skip to content
This repository has been archived by the owner on Feb 5, 2018. It is now read-only.

Commit

Permalink
feat(debug): add options.debug function
Browse files Browse the repository at this point in the history
  • Loading branch information
stevemao committed Feb 13, 2016
1 parent bdce00d commit aa56ae6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
7 changes: 5 additions & 2 deletions lib/get-defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
9 changes: 9 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit aa56ae6

Please sign in to comment.