Skip to content

Conversation

@toastynerd
Copy link

An attempt at #1184, really it just pulls out a callback from the run function and uses it for done(). The issue is old and I didn't see an official response so I thought I would take a stab at it.

@nikolowry
Copy link

+1 this.

I rarely need to use the callback function, but on certain complex projects it's necessary. Anyone wanting to use this without overwriting the source can use this prototype:

grunt.util.task.Task.prototype.run = function () {
    if (typeof(arguments[arguments.length - 1]) === 'function') {
        this._options.done = arguments[arguments.length - 1];
        delete arguments[arguments.length - 1];
    }
    var things = this.parseArgs(arguments).map(this._taskPlusArgs, this);
    var fails = things.filter(function(thing) { return !thing.task; });
    if (fails.length > 0) {
        this._throwIfRunning(new Error('Task "' + fails[0].nameArgs + '" not found.'));
        return this;
    }
    this._push(things);
    return this;
}

Base automatically changed from master to main March 22, 2021 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants