Skip to content

Commit 8249deb

Browse files
committed
Changed option to --include-message
1 parent 29bae75 commit 8249deb

File tree

2 files changed

+34
-11
lines changed

2 files changed

+34
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ There are optional arguments such as:
3131
- `--draft=true` To set the release as a draft. Default: `false`
3232
- `--prerelease=true` To set the release as a prerelease. Default: `false`
3333
- `--prefix=v` Add a prefix to the tag version `e.g. v1.0.1`
34-
- `--includemessages=merges/commits/all` used to filter the messages added to the release notes. Default: `commits`
34+
- `--include-messages=merges/commits/all` used to filter the messages added to the release notes. Default: `commits`

src/index.js

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ function commitMessages(commits) {
5757
return commitObject.commit.message;
5858
});
5959
}
60+
{
61+
62+
key: function(message) { return message.method },
63+
}
6064

6165
/**
6266
* Creates the options to make the release
@@ -69,15 +73,22 @@ function prepareRelease(gren, tagName, commitMessages) {
6973
var body = commitMessages
7074
.slice(0, -1)
7175
.filter(function (message) {
72-
switch(gren.includemessages)
73-
{
74-
case 'merges':
75-
return message.match(/^merge/i);
76-
case "all":
77-
return true;
78-
default:
79-
return !message.match(/^merge/i);
76+
var messageType = gren.options.includeMessages;
77+
var filterMap = {
78+
merges: function(message) {
79+
return message.match(/^merge/i);
80+
},
81+
commits: function(message) {
82+
return !message.match(/^merge/i);
83+
},
84+
all: function(message) { return true; }
85+
};
86+
87+
if(filterMap[messageType]) {
88+
return filterMap[messageType](message);
8089
}
90+
91+
return filterMap.commits(message);
8192
})
8293
.map(createBody)
8394
.join('\n');
@@ -187,6 +198,19 @@ function getLatestRelease(gren) {
187198
});
188199
}
189200

201+
/**
202+
* Transforms a dasherize string into a camel case one.
203+
*
204+
* @param {[string]} value The dasherize string
205+
*
206+
* @return {[string]} The camel case string
207+
*/
208+
function dashToCamelCase(value) {
209+
return value.replace(/-([a-z])/g, function (match) {
210+
return match[1].toUpperCase();
211+
});
212+
}
213+
190214
/**
191215
* Create a literal object of the node module options
192216
*
@@ -200,7 +224,7 @@ function getOptions(args) {
200224
for(var i=2;i<args.length;i++) {
201225
var paramArray = args[i].split('=');
202226

203-
settings[paramArray[0].replace('--', '')] = paramArray[1];
227+
settings[dashToCamelCase(paramArray[0].replace('--', ''))] = paramArray[1];
204228
}
205229

206230
return settings;
@@ -220,7 +244,6 @@ function GithubReleaseNotes(options) {
220244
auth: 'oauth'
221245
});
222246

223-
this.includemessages = this.options.includemessages || "commits";
224247
this.repo = github.getRepo(this.options.username, this.options.repo);
225248
}
226249

0 commit comments

Comments
 (0)