From bb02ce75e3ede68b5af5ba9fd25ba001e53b05a3 Mon Sep 17 00:00:00 2001 From: Mark Kennedy Date: Sun, 22 Feb 2015 14:30:50 +0100 Subject: [PATCH] Bugfix: Ensure before and after tasks run correctly Closes #105. --- CHANGELOG.md | 4 ++++ tasks/grunt-release.js | 23 ++++++++--------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2b8246..5a853a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/tasks/grunt-release.js b/tasks/grunt-release.js index 17019cf..ca49e4b 100644 --- a/tasks/grunt-release.js +++ b/tasks/grunt-release.js @@ -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)) @@ -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'); })