isaacs/fstream-ignore — pull request #8 by SonicHedgehog (2014-07-11 19:50:49+00:00)
Title: Always read ignore files in correct order

Makes sure that ignore files are always read one after another. This is important in the following scenario:

`.gitignore` excludes `index.js` but `.ignore` excludes everything except `index.js` (using `['*'], ['!index.js']`). The result would then be different depending on which file is read first.

Previously, `addIgnoreFile` was called in the correct order which resulted in correct behavior in most cases. However, it was possible that `readFile`’s callback was actually called in a different order, e.g. if `.gitignore` took longer to read from disk.

This is also described in https://github.com/npm/npm/issues/2619 and [caused one of my package releases to contain no actual code](https://github.com/SonicHedgehog/grunt-node-gyp/issues/1#issuecomment-35752259).

I have created a little test case which should fail without this fix as it overrides `fs.readFile` so that it always reads files in the wrong order if they are read in parallel.