Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow the specification of a callback in Task#run #1281

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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