Finally I found a solution in this question (Wait async grunt task to finish). The key to solve this is the use of the function this.async
inside of the registration. A possible solution could be:
'use strict';
module.exports = function (grunt) {
var spawn = require("child_process").spawn,
donePromise;
var createCommit = function (text) {
var i = 0;
var commit = grunt.util.spawn({
cmd: "git",
args: ["commit","-a","-m", text]
}, function() {
callback();
donePromise();
});
};
grunt.registerMultiTask("myplugin", "Plugin to commit awesome things", function () {
donePromise = this.async();
createCommit("0.3.0");
});
};