Skip to content

Instantly share code, notes, and snippets.

@palmerj3
Created December 18, 2015 21:39
Show Gist options
  • Save palmerj3/a98c8b303d24d04e875f to your computer and use it in GitHub Desktop.
Save palmerj3/a98c8b303d24d04e875f to your computer and use it in GitHub Desktop.
var oldRunTaskFn = grunt.util.task.Task.prototype.runTaskFn;
grunt.util.task.Task.prototype.runTaskFn = function () {
var taskName = arguments[0].name
var invokeFn = arguments[1];
var asyncFn = arguments[2];
var start = (new Date()).getTime();
// New Async "Done" function
var newAsyncFn = function () {
fs.appendFileSync('.tmpBuildSteps', [start, (new Date()).getTime(), taskName].join(',') + '\n');
asyncFn.apply(this, arguments);
}
// Overwrite function argument
// So we can track when task completes
if (typeof asyncFn === 'function') {
arguments[2] = newAsyncFn;
}
// Call original
oldRunTaskFn.apply(this, arguments);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment