If you wish to be a success in the world, promise everything, deliver nothing. (Napoleon Bonaparte)
Grunt as promised helps you write async custom tasks through promises
npm install grunt-as-promised --save-dev
Require grunt-as-promised
in your Gruntfile.js
:
var gap = require('grunt-as-promised');
Then enhance grunt:
gap.configure(grunt);
Finally use grunt.registerPromiseTask
to define tasks as functions returning a promise:
grunt.registerPromiseTask('inline', function () {
return doSomething().then(function() {
return doSomethingElse();
});
};
var gap = require('grunt-as-promised');
module.exports = function (grunt) {
gap.configure(grunt);
grunt.registerPromiseTask('inline', function () {
// ...
};
};
More examples are available in examples.