manuelschneider/grunt-markedman — pull request #1 by davejamesmiller (2014-06-01 21:44:14+00:00)
Title: Prevent done() being called multiple times

The `done()` method is being called multiple times, which creates problems for subsequent tasks. Two issues:

1. `jobs.pending === 0` is always true. I'm not certain, but I suspect `markedMan()` is running the callback synchronously, so `jobs.pending--` runs before the next file's `jobs.pending++` (so it goes 0, 1, 0, 1, ... instead of 0, 1, 2, ..., 2, 1, 0). Instead I've initialised `jobs.pending` to the number of files at the start.

2. If there's more than one error, `done(err)` is called every time. I've modified it to always call `done()` once at the end. (Also it now calls `done(false)`, as in the [Grunt docs](http://gruntjs.com/creating-tasks), rather than `done(err)` - not sure if that's strictly necessary.)