#1665·grunt

Request: have grunt automatically enter async mode if task returns a promise

Author: elliot-nelsonCreated Mar 9, 2019Updated Nov 19, 2025

Every grunt task I've ever seen looks, essentially, like this:

grunt.registerTask('build', function () {
    const done = this.async();

    callSomeModule()
    .then(() => done())
    .catch(error => {
        grunt.fail.warn(error);
        done(false);
    });
});

It would be nice if by default, grunt recognized a Promise return value and did the boilerplate for you (spitting a stack trace to warn if the promise is rejected, continuing if the promise resolved).

I'd be open to to putting up a tentative PR, if this sounds like something that could be added.

Example desired syntax:

grunt.registerTask('build', function () {
    return callSomeModule();
});