arbus/grunt-aglio — pull request #17 by cjthompson (2014-08-29 17:57:27+00:00)
Title: Use Promises to ensure that every file is rendered before calling done()

Grunt was existing as soon as done was called, which is currently in the aglio.render callback. The problem is that the first file that completed the aglio build process would trigger done() and grunt would exit, even if there were other files being rendered.

This PR uses when.js promises to fix this problem. It runs a mapper function against `this.files` that returns a `Promise` that resolves when `aglio.render` completes. The array of Promises is passed to `when.all` which only resolves when all the promises in the array resolve. `done()` is only called after when.all resolves all the promises.

I added a test to verify that the code works against a configuration with 5 separate configurations.