Skip to content

Commit

Permalink
Changed option to --include-message
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcanessa committed Mar 3, 2016
1 parent 29bae75 commit 8249deb
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
- `--include-messages=merges/commits/all` used to filter the messages added to the release notes. Default: `commits`
43 changes: 33 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ function commitMessages(commits) {
return commitObject.commit.message;
});
}
{

key: function(message) { return message.method },
}

/**
* Creates the options to make the release
Expand All @@ -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');
Expand Down Expand Up @@ -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
*
Expand All @@ -200,7 +224,7 @@ function getOptions(args) {
for(var i=2;i<args.length;i++) {
var paramArray = args[i].split('=');

settings[paramArray[0].replace('--', '')] = paramArray[1];
settings[dashToCamelCase(paramArray[0].replace('--', ''))] = paramArray[1];
}

return settings;
Expand All @@ -220,7 +244,6 @@ function GithubReleaseNotes(options) {
auth: 'oauth'
});

this.includemessages = this.options.includemessages || "commits";
this.repo = github.getRepo(this.options.username, this.options.repo);
}

Expand Down

0 comments on commit 8249deb

Please sign in to comment.