grunt
grunt copied to clipboard
Request: have grunt automatically enter async mode if task returns a promise
trafficstars
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();
});
similarly it would be awesome to support this syntax:
grunt.registerTask('build', async function () {
await callSomeModule();
});