Skip to content

Commit

Permalink
Bugfix: Ensure before and after tasks run correctly
Browse files Browse the repository at this point in the history
Closes #105.
  • Loading branch information
Mark Kennedy authored and drublic committed Feb 22, 2015
1 parent 92e85e6 commit bb02ce7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* Bugfix: Ensure before and after tasks run correctly
(!) Please be sure to use beforeBump, afterBump, beforeRelease and
afterRelease as documented in README.md.

### v0.11.0 - 2015-02-05
* Adding custom tasks to run before or after bump and release

Expand Down
23 changes: 8 additions & 15 deletions tasks/grunt-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,29 +243,22 @@ module.exports = function(grunt){
}

function runTasks(taskName) {
var map = {
beforeBump: 'beforeBumpTasks',
afterBump: 'afterBumpTasks',
beforeRelease: 'beforeReleaseTasks',
afterRelease: 'afterReleaseTasks'
};
return function () {
var method = map[taskName],
tasks = options[method];
var tasks = options[taskName];
return Q.fcall(function () {
if (tasks.length) {
grunt.log.ok('running ' + method + ' ');
grunt.log.ok('running ' + taskName + ' ');
if (!nowrite) {
grunt.task.run(tasks);
}
}
}
});
}

new Q()
.then(ifEnabled('beforeBumpTasks', runTasks('beforeBump')))
.then(ifEnabled('beforeBump', runTasks('beforeBump')))
.then(ifEnabled('bump', bump))
.then(ifEnabled('afterBumpTasks', runTasks('afterBump')))
.then(ifEnabled('beforeReleaseTasks', runTasks('beforeRelease')))
.then(ifEnabled('afterBump', runTasks('afterBump')))
.then(ifEnabled('beforeRelease', runTasks('beforeRelease')))
.then(ifEnabled('changelog', changelog))
.then(ifEnabled('add', add))
.then(ifEnabled('commit', commit))
Expand All @@ -274,7 +267,7 @@ module.exports = function(grunt){
.then(ifEnabled('pushTags', pushTags))
.then(ifEnabled('npm', publish))
.then(ifEnabled('github', githubRelease))
.then(ifEnabled('afterReleaseTasks', runTasks('afterRelease')))
.then(ifEnabled('afterRelease', runTasks('afterRelease')))
.catch(function(msg){
grunt.fail.warn(msg || 'release failed');
})
Expand Down

0 comments on commit bb02ce7

Please sign in to comment.