diff --git a/README.md b/README.md index d71a6beb..27ecfac4 100644 --- a/README.md +++ b/README.md @@ -31,4 +31,4 @@ There are optional arguments such as: - `--draft=true` To set the release as a draft. Default: `false` - `--prerelease=true` To set the release as a prerelease. Default: `false` - `--prefix=v` Add a prefix to the tag version `e.g. v1.0.1` -- `--includemessages=merges/commits/all` used to filter the messages added to the release notes. Default: `commits` \ No newline at end of file +- `--include-messages=merges/commits/all` used to filter the messages added to the release notes. Default: `commits` \ No newline at end of file diff --git a/src/index.js b/src/index.js index 744874b1..5b910075 100644 --- a/src/index.js +++ b/src/index.js @@ -57,6 +57,10 @@ function commitMessages(commits) { return commitObject.commit.message; }); } +{ + + key: function(message) { return message.method }, +} /** * Creates the options to make the release @@ -69,15 +73,22 @@ function prepareRelease(gren, tagName, commitMessages) { var body = commitMessages .slice(0, -1) .filter(function (message) { - switch(gren.includemessages) - { - case 'merges': - return message.match(/^merge/i); - case "all": - return true; - default: - return !message.match(/^merge/i); + var messageType = gren.options.includeMessages; + var filterMap = { + merges: function(message) { + return message.match(/^merge/i); + }, + commits: function(message) { + return !message.match(/^merge/i); + }, + all: function(message) { return true; } + }; + + if(filterMap[messageType]) { + return filterMap[messageType](message); } + + return filterMap.commits(message); }) .map(createBody) .join('\n'); @@ -187,6 +198,19 @@ function getLatestRelease(gren) { }); } +/** + * Transforms a dasherize string into a camel case one. + * + * @param {[string]} value The dasherize string + * + * @return {[string]} The camel case string + */ +function dashToCamelCase(value) { + return value.replace(/-([a-z])/g, function (match) { + return match[1].toUpperCase(); + }); +} + /** * Create a literal object of the node module options * @@ -200,7 +224,7 @@ function getOptions(args) { for(var i=2;i