isaacs/npm — pull request #2791 by mfncooper (2012-09-08 16:43:48+00:00)
Title: Fix EPIPE workaround for Darwin

The current workaround for the EPIPE error on Darwin, when running `. <(npm completion)`, does not work because the errno that comes back from Node is actually a string, rather than the numeric error code it's being compared against. This patch fixes that test.

With the test fixed, there's another error, because we call our callback twice. The first time is when we get called back from write(), and the second when we process the EPIPE error. Thus the patch includes code to ensure that we only call our callback once.