joeybaker/remapify — pull request #26 by jmm (2014-12-31 16:35:41+00:00)
Title: #24 "Error: write after end" with browserify 7.x

This is meant to fix #24. I don't know how browserify < 7 worked, but it seems that in >= 7 its pipeline can finish before remapify's globbing and addition of the aliasify transform finishes. I think it's necessary to do the globbing synchronously. This PR makes the globbing synchronous and adjusts the code consuming the glob results accordingly. `globMatch()` is exactly the same -- it's just passed to a different method and its indentation level changed.

I haven't added any new tests (not yet anyway). After a slight adjustment, all of the existing tests pass. Each test followed a sequence of 1) run plugin, 2) register event handler. I had to swap the sequence because remapify was emitting events before handlers were registered. (I suggest diffing that commit with `--patience`.)

I haven't tested this extensively, but with a simple trial it works with browserify 6-8, and like I said the tests pass.

I did try retaining the asynchronous globbing and utilizing streams to make everything work, but I couldn't work that out.